-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
51 lines (42 loc) · 1.2 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
50
51
'use strict'
const Funnel = require('broccoli-funnel')
const mergeTrees = require('broccoli-merge-trees')
const path = require('path')
const replace = require('broccoli-string-replace')
module.exports = {
name: 'redux-saga',
treeForAddon (tree) {
const reduxSagaPath = path.dirname(require.resolve('redux-saga/es/index.js'));
let reduxSagaTree = this.treeGenerator(reduxSagaPath);
reduxSagaTree = new Funnel(reduxSagaTree, {
include: [
'**/*.js'
]
});
let addon = this.addons.find(addon => addon.name === 'ember-cli-babel');
reduxSagaTree = addon.transpileTree(reduxSagaTree, {
babel: {
plugins: ['transform-object-rest-spread']
},
'ember-cli-babel': {
compileModules: false
}
});
reduxSagaTree = replace(reduxSagaTree, {
files: ['**/internal/*.js'],
patterns: [
{
match: /process\.env\.NODE_ENV/g,
replacement: "'production'"
}
]
})
if (!tree) {
return this._super.treeForAddon.call(this, reduxSagaTree)
}
const trees = mergeTrees([reduxSagaTree, tree], {
overwrite: true
})
return this._super.treeForAddon.call(this, trees)
}
}