-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
49 lines (41 loc) · 1.28 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* eslint-env node */
'use strict';
const mergeTrees = require('broccoli-merge-trees');
const path = require('path');
const replace = require('broccoli-string-replace');
module.exports = {
name: 'redux-persist',
treeForAddon (tree) {
const persistPath = path.dirname(require.resolve('redux-persist/src/index.js'));
const denodifiedPersist = replace(persistPath, {
files: [ '**/*.js' ],
patterns: [
{
match: /process\.env\.NODE_ENV/g,
replacement: JSON.stringify(process.env.EMBER_ENV)
},
{
match: /import isPlainObject from 'lodash\/isPlainObject'/g,
replacement: "import lodash from 'lodash'\nconst isPlainObject = lodash.isPlainObject"
}
]
});
let addon = this.addons.find(addon => addon.name === 'ember-cli-babel');
let persistTree = addon.transpileTree(denodifiedPersist, {
babel: {
plugins: ['transform-object-rest-spread'],
presets: ['stage-2']
},
'ember-cli-babel': {
compileModules: false
}
});
if (!tree) {
return this._super.treeForAddon.call(this, persistTree);
}
const trees = mergeTrees([persistTree, tree], {
overwrite: true
});
return this._super.treeForAddon.call(this, trees);
}
}