forked from angular/angular-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ts
238 lines (224 loc) · 6.24 KB
/
build.ts
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
import { CliConfig } from '../models/config';
import { BuildOptions } from '../models/build-options';
import { Version } from '../upgrade/version';
import { oneLine } from 'common-tags';
const Command = require('../ember-cli/lib/models/command');
const config = CliConfig.fromProject() || CliConfig.fromGlobal();
const buildConfigDefaults = config.getPaths('defaults.build', [
'sourcemaps', 'baseHref', 'progress', 'poll', 'deleteOutputPath', 'preserveSymlinks',
'showCircularDependencies', 'commonChunk', 'namedChunks'
]);
// defaults for BuildOptions
export const baseBuildCommandOptions: any = [
{
name: 'target',
type: String,
default: 'development',
aliases: ['t', { 'dev': 'development' }, { 'prod': 'production' }],
description: 'Defines the build target.'
},
{
name: 'environment',
type: String,
aliases: ['e'],
description: 'Defines the build environment.'
},
{
name: 'output-path',
type: 'Path',
aliases: ['op'],
description: 'Path where output will be placed.'
},
{
name: 'aot',
type: Boolean,
description: 'Build using Ahead of Time compilation.'
},
{
name: 'sourcemaps',
type: Boolean,
aliases: ['sm', 'sourcemap'],
description: 'Output sourcemaps.',
default: buildConfigDefaults['sourcemaps']
},
{
name: 'vendor-chunk',
type: Boolean,
aliases: ['vc'],
description: 'Use a separate bundle containing only vendor libraries.'
},
{
name: 'common-chunk',
type: Boolean,
default: buildConfigDefaults['commonChunk'],
aliases: ['cc'],
description: 'Use a separate bundle containing code used across multiple bundles.'
},
{
name: 'base-href',
type: String,
aliases: ['bh'],
description: 'Base url for the application being built.',
default: buildConfigDefaults['baseHref']
},
{
name: 'deploy-url',
type: String,
aliases: ['d'],
description: 'URL where files will be deployed.'
},
{
name: 'verbose',
type: Boolean,
default: false,
aliases: ['v'],
description: 'Adds more details to output logging.'
},
{
name: 'progress',
type: Boolean,
aliases: ['pr'],
description: 'Log progress to the console while building.',
default: buildConfigDefaults['progress']
},
{
name: 'i18n-file',
type: String,
description: 'Localization file to use for i18n.'
},
{
name: 'i18n-format',
type: String,
description: 'Format of the localization file specified with --i18n-file.'
},
{
name: 'locale',
type: String,
description: 'Locale to use for i18n.'
},
{
name: 'missing-translation',
type: String,
description: 'How to handle missing translations for i18n.'
},
{
name: 'extract-css',
type: Boolean,
aliases: ['ec'],
description: 'Extract css from global styles onto css files instead of js ones.'
},
{
name: 'watch',
type: Boolean,
default: false,
aliases: ['w'],
description: 'Run build when files change.'
},
{
name: 'output-hashing',
type: String,
values: ['none', 'all', 'media', 'bundles'],
description: 'Define the output filename cache-busting hashing mode.',
aliases: ['oh']
},
{
name: 'poll',
type: Number,
description: 'Enable and define the file watching poll time period (milliseconds).',
default: buildConfigDefaults['poll']
},
{
name: 'app',
type: String,
aliases: ['a'],
description: 'Specifies app name or index to use.'
},
{
name: 'delete-output-path',
type: Boolean,
aliases: ['dop'],
description: 'Delete output path before build.',
default: buildConfigDefaults['deleteOutputPath'],
},
{
name: 'preserve-symlinks',
type: Boolean,
description: 'Do not use the real path when resolving modules.',
default: buildConfigDefaults['preserveSymlinks']
},
{
name: 'extract-licenses',
type: Boolean,
default: true,
description: 'Extract all licenses in a separate file, in the case of production builds only.'
},
{
name: 'show-circular-dependencies',
type: Boolean,
aliases: ['scd'],
description: 'Show circular dependency warnings on builds.',
default: buildConfigDefaults['showCircularDependencies']
},
{
name: 'build-optimizer',
type: Boolean,
default: false,
description: '(Experimental) Enables @angular-devkit/build-optimizer '
+ 'optimizations when using `--aot`.'
},
{
name: 'named-chunks',
type: Boolean,
aliases: ['nc'],
description: 'Use file name for lazy loaded chunks.',
default: buildConfigDefaults['namedChunks']
},
{
name: 'subresource-integrity',
type: Boolean,
default: false,
aliases: ['sri'],
description: 'Enables the use of subresource integrity validation.'
},
{
name: 'bundle-dependencies',
type: ['none', 'all'],
default: 'none',
description: 'Available on server platform only. Which external dependencies to bundle into '
+ 'the module. By default, all of node_modules will be kept as requires.'
}
];
export interface BuildTaskOptions extends BuildOptions {
statsJson?: boolean;
}
const BuildCommand = Command.extend({
name: 'build',
description: 'Builds your app and places it into the output path (dist/ by default).',
aliases: ['b'],
availableOptions: baseBuildCommandOptions.concat([
{
name: 'stats-json',
type: Boolean,
default: false,
description: oneLine`Generates a \`stats.json\` file which can be analyzed using tools
such as: \`webpack-bundle-analyzer\` or https://webpack.github.io/analyse.`
}
]),
run: function (commandOptions: BuildTaskOptions) {
// Check Angular and TypeScript versions.
Version.assertAngularVersionIs2_3_1OrHigher(this.project.root);
Version.assertTypescriptVersion(this.project.root);
// Default vendor chunk to false when build optimizer is on.
if (commandOptions.vendorChunk === undefined) {
commandOptions.vendorChunk = !commandOptions.buildOptimizer;
}
const BuildTask = require('../tasks/build').default;
const buildTask = new BuildTask({
project: this.project,
ui: this.ui,
});
return buildTask.run(commandOptions);
}
});
BuildCommand.overrideCore = true;
export default BuildCommand;