-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Expand file tree
/
Copy pathmultiple-configs.ts
More file actions
63 lines (59 loc) · 2.37 KB
/
multiple-configs.ts
File metadata and controls
63 lines (59 loc) · 2.37 KB
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
import { getGlobalVariable } from '../../utils/env';
import { expectFileToExist } from '../../utils/fs';
import { ng } from '../../utils/process';
import { updateJsonFile } from '../../utils/project';
import { expectToFail } from '../../utils/utils';
export default async function () {
// TODO: Restructure to support application builder option
// This only needs to be tested once since it is really testing the CLI itself and not the builders
if (getGlobalVariable('argv')['esbuild']) {
return;
}
await updateJsonFile('angular.json', (workspaceJson) => {
const appArchitect = workspaceJson.projects['test-project'].architect;
// These are the default options, that we'll overwrite in subsequent configs.
// sourceMap defaults to true
appArchitect['build'] = {
...appArchitect['build'],
defaultConfiguration: undefined,
options: {
...appArchitect['build'].options,
optimization: false,
sourceMap: true,
outputHashing: 'none',
vendorChunk: true,
styles: ['src/styles.css'],
scripts: [],
budgets: [],
},
configurations: {
development: {
sourceMap: true,
},
one: {
assets: [],
},
two: {
sourceMap: false,
},
},
};
return workspaceJson;
});
// Test the base configuration.
await ng('build', '--configuration=development');
await expectFileToExist('dist/test-project/browser/favicon.ico');
await expectFileToExist('dist/test-project/browser/main.js.map');
await expectFileToExist('dist/test-project/browser/vendor.js');
await ng('build');
await expectFileToExist('dist/test-project/browser/styles.css');
// Use two configurations.
await ng('build', '--configuration=one,two', '--vendor-chunk=false');
await expectToFail(() => expectFileToExist('dist/test-project/browser/favicon.ico'));
await expectToFail(() => expectFileToExist('dist/test-project/browser/main.js.map'));
// Use two configurations and two overrides, one of which overrides a config.
await ng('build', '--configuration=one,two', '--vendor-chunk=false', '--source-map=true');
await expectToFail(() => expectFileToExist('dist/test-project/browser/favicon.ico'));
await expectFileToExist('dist/test-project/browser/main.js.map');
await expectToFail(() => expectFileToExist('dist/test-project/browser/vendor.js'));
}