Skip to content

Instantly share code, notes, and snippets.

@lifeart
Last active March 11, 2018 21:07
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save lifeart/949d867ba5f5455f8d955d9c9dc3610d to your computer and use it in GitHub Desktop.
Ember-cli-es6-imports
// install ember-cli-es6-transform
function importFromNPM(app,moduleName) {
let relPath = `node_modules/${moduleName}`;
let nodePath = `./${relPath}`;
let config = require(`${nodePath}/package.json`);
if (config.style) {
app.import(`${relPath}/${config.style}`);
}
app.import(`${relPath}/${config.module}`, {
using: [
{ transformation: 'es6', as: config.name }
]
})
}
//usage inside ember-cli-build
/*
importFromNPM(app, 'cropperjs');
*/
// in your app
/*
import cropper from 'cropperjs'
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment