-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdenali-build.js
44 lines (39 loc) · 1.2 KB
/
denali-build.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
const { AddonBuilder } = require('@denali-js/cli');
const fs = require('fs');
const path = require('path');
const MergeTree = require('broccoli-merge-trees');
const BabelTree = require('broccoli-babel-transpiler');
const Funnel = require('broccoli-funnel');
const debug = require('debug')('@denali-js/babel');
module.exports = class DenaliBabelBuilder extends AddonBuilder {
processSelf(tree, dir) {
return new MergeTree([ tree, this.transpile(tree, dir) ], { overwrite: true });
}
processParent(tree, dir) {
return new MergeTree([ tree, this.transpile(tree, dir) ], { overwrite: true });
}
transpile(tree, dir) {
let babelrcPath = path.join(dir, '.babelrc');
let options;
if (fs.existsSync(babelrcPath)) {
options = JSON.parse(fs.readFileSync(babelrcPath, 'utf-8'));
} else {
options = {
presets: [
["env", {
targets: {
node: "current"
}
}]
],
ignore: [
'blueprints/*/files/**',
'test/dummy/**'
]
};
}
options.sourceMaps = 'inline';
options.sourceRoot = dir;
return new BabelTree(new Funnel(tree, { exclude: options.ignore }), options);
}
};