forked from angular/components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
angular-cli-build.js
111 lines (97 loc) · 2.82 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
'use strict';
const fs = require('fs');
const path = require('path');
// Import the require hook. Enables us to require TS files natively.
require('ts-node/register');
const Angular2App = require('angular-cli/lib/broccoli/angular2-app');
const Funnel = require('broccoli-funnel');
const MergeTree = require('broccoli-merge-trees');
const autoPrefixerTree = require('broccoli-autoprefixer');
module.exports = function(defaults) {
// The Angular Application tree.
const appTree = _buildAppTree(defaults);
// The CSS tree that is auto prefixed with browser support.
const cssAutoprefixed = autoPrefixerTree(new Funnel(appTree, {
include: [ '**/*.css' ]
}));
// Include the scss sources in the output for when we publish.
const scssSources = new Funnel('src', {include: ['**/*.scss']});
return new MergeTree([appTree, cssAutoprefixed, scssSources], { overwrite: true });
};
/**
* Build the Broccoli Tree containing all the files used as the input to the Demo Angular2App.
*/
function _buildDemoAppInputTree() {
return new MergeTree([
new Funnel('typings', {
destDir: 'typings'
}),
new Funnel('src', {
include: ['components/**/*', 'core/**/*'],
destDir: 'src/demo-app'
}),
new Funnel('src/demo-app', {
destDir: 'src/demo-app'
})
]);
}
/**
* Build the Broccoli Tree containing all the files used as the input to the e2e Angular2App.
*/
function _buildE2EAppInputTree() {
return new MergeTree([
new Funnel('typings', {
destDir: 'typings'
}),
new Funnel('src', {
include: ['components/**/*', 'core/**/*'],
destDir: 'src/e2e-app'
}),
new Funnel('src/e2e-app', {
destDir: 'src/e2e-app'
})
]);
}
/**
* Build the Broccoli Tree that contains the Angular2 App. This picks between E2E, Example or Demo
* app.
* @param defaults The default objects from AngularCLI (deprecated).
* @returns {Angular2App}
*/
function _buildAppTree(defaults) {
let inputNode;
let sourceDir;
switch(process.env['MD_APP']) {
case 'e2e':
inputNode = _buildE2EAppInputTree();
sourceDir = 'src/e2e-app';
break;
default:
inputNode = _buildDemoAppInputTree();
sourceDir = 'src/demo-app';
}
return new Angular2App(defaults, inputNode, {
sourceDir: sourceDir,
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: {},
sassCompiler: {
includePaths: [
'src/core/style'
]
},
vendorNpmFiles: [
'systemjs/dist/system-polyfills.js',
'systemjs/dist/system.src.js',
'zone.js/dist/*.+(js|js.map)',
'core-js/client/core.js',
'rxjs/**/*.+(js|js.map)',
'@angular/**/*.+(js|js.map)',
'hammerjs/*.min.+(js|js.map)'
]
});
}