-
Notifications
You must be signed in to change notification settings - Fork 1
/
angular-cli-build.js
65 lines (59 loc) · 1.93 KB
/
angular-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
const Angular2App = require('angular-cli/lib/broccoli/angular2-app');
const compileSass = require('broccoli-sass');
const compileCSS = require('broccoli-postcss');
const cssNext = require('postcss-cssnext');
const cssNano = require('cssnano');
const mergeTrees = require('broccoli-merge-trees');
const _ = require('lodash');
const glob = require('glob');
var options = {
plugins: [
{
module: cssNext,
options: {
browsers: ['> 1%'],
warnForDuplicates: false
}
},
{
module: cssNano,
options: {
safe: true,
sourcemap: true
}
}
]
};
module.exports = function (defaults) {
let appTree = new Angular2App(defaults, {
sassCompiler: {
cacheExclude: [/\/_[^\/]+$/]
},
polyfills: [
'vendor/core-js/client/core.js',
'vendor/systemjs/dist/system.src.js',
'vendor/zone.js/dist/zone.js',
'vendor/hammerjs/hammer.min.js'
],
tsCompiler: {},
vendorNpmFiles: [
'systemjs/dist/system-polyfills.js',
'systemjs/dist/system.src.js',
'zone.js/dist/**/*.+(js|js.map)',
'core-js/client/core.js',
'es6-shim/es6-shim.js',
'reflect-metadata/**/*.+(js|js.map)',
'rxjs/**/*.+(js|js.map)',
'@angular/**/*.+(js|js.map|css)',
'@angular2-material/**/*.+(js|js.map|css)',
'hammerjs/*.min.+(js|js.map)',
'symbol-observable/**/*.+(js|js.map)'
]
});
let sass = mergeTrees(_.map(glob.sync('src/**/*.scss'), function (sassFile) {
sassFile = sassFile.replace('src/', '');
return compileSass(['src'], sassFile, sassFile.replace(/.scss$/, '.css'));
}));
let css = compileCSS(sass, options);
return mergeTrees([appTree, sass, css], {overwrite: true});
};