forked from emberjs/ember.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ember-cli-build.js
73 lines (59 loc) · 2.71 KB
/
ember-cli-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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* jshint node: true */
// To create fast production builds (without ES3 support, minification, derequire, or JSHint)
// run the following:
//
// DISABLE_ES3=true DISABLE_JSCS=true DISABLE_JSHINT=true DISABLE_MIN=true DISABLE_DEREQUIRE=true ember serve --environment=production
var fs = require('fs');
var EmberBuild = require('emberjs-build');
var packages = require('./lib/packages');
var applyFeatureFlags = require('babel-plugin-feature-flags');
var filterImports = require('babel-plugin-filter-imports');
var vendoredPackage = require('emberjs-build/lib/vendored-package');
var htmlbarsPackage = require('emberjs-build/lib/htmlbars-package');
var vendoredES6Package = require('emberjs-build/lib/es6-vendored-package');
var featuresJson = fs.readFileSync('./features.json', { encoding: 'utf8' });
function babelConfigFor(environment) {
var isDevelopment = (environment === 'development');
var isProduction = (environment === 'production');
var features = JSON.parse(featuresJson).features;
features['mandatory-setter'] = isDevelopment;
var plugins = [];
plugins.push(applyFeatureFlags({
import: { module: 'ember-metal/features' },
features: features
}));
if (isProduction) {
plugins.push(filterImports({
'ember-metal/debug': ['assert', 'debug', 'deprecate', 'info', 'runInDebug', 'warn', 'debugSeal']
}));
}
return { plugins: plugins };
}
module.exports = function() {
var emberBuild = new EmberBuild({
babel: {
development: babelConfigFor('development'),
production: babelConfigFor('production')
},
htmlbars: require('htmlbars'),
packages: packages,
vendoredPackages: {
'loader': vendoredPackage('loader'),
'rsvp': vendoredES6Package('rsvp'),
'backburner': vendoredES6Package('backburner'),
'router': vendoredES6Package('router.js'),
'dag-map': vendoredES6Package('dag-map'),
'route-recognizer': htmlbarsPackage('route-recognizer', { libPath: 'node_modules/route-recognizer/dist/es6/' }),
'dom-helper': htmlbarsPackage('dom-helper'),
'morph-range': htmlbarsPackage('morph-range'),
'morph-attr': htmlbarsPackage('morph-attr'),
'htmlbars-runtime': htmlbarsPackage('htmlbars-runtime'),
'htmlbars-compiler': htmlbarsPackage('htmlbars-compiler'),
'htmlbars-syntax': htmlbarsPackage('htmlbars-syntax'),
'simple-html-tokenizer': htmlbarsPackage('simple-html-tokenizer'),
'htmlbars-test-helpers': htmlbarsPackage('htmlbars-test-helpers', { singleFile: true }),
'htmlbars-util': htmlbarsPackage('htmlbars-util')
}
});
return emberBuild.getDistTrees();
};