Skip to content

Instantly share code, notes, and snippets.

@fivetanley
Created November 22, 2016 22:27
Show Gist options
  • Save fivetanley/3fd24d34d7709ed48d8266648cc6077f to your computer and use it in GitHub Desktop.
Save fivetanley/3fd24d34d7709ed48d8266648cc6077f to your computer and use it in GitHub Desktop.
/* jshint node: true */
'use strict';
var path = require('path');
var mergeTrees = require('broccoli-merge-trees');
var babel = require('broccoli-babel-transpiler');
var lodashPlugin = require('babel-plugin-lodash');
module.exports = {
name: 'lodash',
setupPreprocessorRegistry: function(type, registry) {
var addon = this;
registry.add('js', {
name: 'ember-lodash',
ext: 'js',
toTree: function(tree) {
return babel(tree, { plugins: [ lodashPlugin ] });
}
});
},
treeForAddon: function(tree) {
var lodashPath = path.dirname(require.resolve('lodash-es/lodash.js'));
var lodashTree = this.treeGenerator(lodashPath);
var trees = mergeTrees([lodashTree, tree], {
overwrite: true
});
return this._super.treeForAddon.call(this, trees);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment