@jasonmit/ember-cli-node-modules-to-vendor

0.2.2 • Public • Published

ember-cli-node-modules-to-vendor

Greenkeeper badge npm version Build Status

Easily import packages (non ember addons) from node_modules (you can import from any folder if you want to)

Installation

ember install ember-cli-node-modules-to-vendor

Usage

// ember-cli-build.js

// ...

var app = new EmberApp(defaults, {
  nodeModulesToVendor: [
    'node_modules/some-package/dist/js'
  ]
});

// then you can easily do
app.import('vendor/a-file-from-the-folder-above.js');

// ...

Advanced Usage

You can supply a tree if you want finer control:

// ember-cli-build.js

var Funnel = require('broccoli-funnel');
var UnwatchedDir = require('broccoli-source').UnwatchedDir;
// ...

var app = new EmberApp(defaults, {
  nodeModulesToVendor: [
    /* UnwatchedDir is optional, but it is rare to need a watcher assigned to a node_modules dependencies */
    new Funnel(new UnwatchedDir('node_modules/some-package/dist/js'), {
      destDir: 'some-package',
      files: ['only-this-file.js']
    })
  ]
});

app.import('vendor/some-package/only-this-file.js');

Note: omitting the destDir option will place the file directly into the vendor folder, so app.import('vendor/only-this-file.js') would be your import instead.

You can conditionally import:

// ember-cli-build.js

// ...

function isDevelopment() {
  return EmberApp.env !== 'production';
}

// ...

var nodeModulesToVendor = [];
if (isDevelopment()) {
  nodeModulesToVendor.push('node_modules/dev-helper/dist');
}

var app = new EmberApp(defaults, {
  nodeModulesToVendor: nodeModulesToVendor
});

if (isDevelopment()) {
  app.import('vendor/a-file-from-the-folder-above.js');
}

// ...

Readme

Keywords

Package Sidebar

Install

npm i @jasonmit/ember-cli-node-modules-to-vendor

Weekly Downloads

0

Version

0.2.2

License

MIT

Last publish

Collaborators

  • jasonmit