0.3.0 • Published 7 years ago

ember-cli-node-modules-to-vendor v0.3.0

Weekly downloads
949
License
MIT
Repository
github
Last release
7 years ago

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');
}

// ...
0.3.0

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.2

7 years ago

0.1.1

8 years ago

0.1.0

8 years ago