forked from angular/angular-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ts
75 lines (67 loc) · 2.31 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
const Command = require('../ember-cli/lib/models/command');
import WebpackBuild from '../tasks/build-webpack';
import WebpackBuildWatch from '../tasks/build-webpack-watch';
export interface BuildOptions {
target?: string;
environment?: string;
outputPath?: string;
watch?: boolean;
watcher?: string;
supressSizes: boolean;
baseHref?: string;
aot?: boolean;
sourcemap?: boolean;
vendorChunk?: boolean;
}
const BuildCommand = Command.extend({
name: 'build',
description: 'Builds your app and places it into the output path (dist/ by default).',
aliases: ['b'],
availableOptions: [
{
name: 'target',
type: String,
default: 'development',
aliases: ['t', { 'dev': 'development' }, { 'prod': 'production' }]
},
{ name: 'environment', type: String, default: '', aliases: ['e'] },
{ name: 'output-path', type: 'Path', default: null, aliases: ['o'] },
{ name: 'watch', type: Boolean, default: false, aliases: ['w'] },
{ name: 'watcher', type: String },
{ name: 'suppress-sizes', type: Boolean, default: false },
{ name: 'base-href', type: String, default: null, aliases: ['bh'] },
{ name: 'aot', type: Boolean, default: false },
{ name: 'sourcemap', type: Boolean, default: true, aliases: ['sm'] },
{ name: 'vendor-chunk', type: Boolean, default: true }
],
run: function (commandOptions: BuildOptions) {
if (commandOptions.environment === '') {
if (commandOptions.target === 'development') {
commandOptions.environment = 'dev';
}
if (commandOptions.target === 'production') {
commandOptions.environment = 'prod';
}
}
const project = this.project;
const ui = this.ui;
const buildTask = commandOptions.watch ?
new WebpackBuildWatch({
cliProject: project,
ui: ui,
outputPath: commandOptions.outputPath,
target: commandOptions.target,
environment: commandOptions.environment
}) :
new WebpackBuild({
cliProject: project,
ui: ui,
outputPath: commandOptions.outputPath,
target: commandOptions.target,
environment: commandOptions.environment,
});
return buildTask.run(commandOptions);
}
});
BuildCommand.overrideCore = true;
export default BuildCommand;