GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(@angular/cli): support using multiple configurations · angular/angular-cli@65c2a19

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/angular/cli/models
    • architect-command.ts
  • tests/legacy-cli/e2e/tests/build
    • multiple-configs.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/angular/cli/models/architect-command.ts‎

Copy file name to clipboardExpand all lines: packages/angular/cli/models/architect-command.ts
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,15 @@ export abstract class ArchitectCommand<
366366
} else {
367367
project = commandOptions.project;
368368
target = this.target;
369-
configuration = commandOptions.configuration;
370-
if (!configuration && commandOptions.prod) {
369+
if (commandOptions.prod) {
370+
// The --prod flag will always be the first configuration, available to be overwritten
371+
// by following configurations.
371372
configuration = 'production';
372373
}
374+
if (commandOptions.configuration) {
375+
configuration =
376+
`${configuration ? `${configuration},` : ''}${commandOptions.configuration}`;
377+
}
373378
}
374379

375380
if (!project) {
Collapse file

‎tests/legacy-cli/e2e/tests/build/multiple-configs.ts‎

Copy file name to clipboard
+71Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import { expectFileToExist } from '../../utils/fs';
2+
import { ng } from '../../utils/process';
3+
import { updateJsonFile } from '../../utils/project';
4+
import { expectToFail } from '../../utils/utils';
5+
6+
export default async function () {
7+
await updateJsonFile('angular.json', workspaceJson => {
8+
const appArchitect = workspaceJson.projects['test-project'].architect;
9+
// These are the default options, that we'll overwrite in subsequent configs.
10+
// extractCss defaults to false
11+
// sourceMap defaults to true
12+
appArchitect['options'] = {
13+
outputPath: 'dist/latest-project',
14+
index: 'src/index.html',
15+
main: 'src/main.ts',
16+
polyfills: 'src/polyfills.ts',
17+
tsConfig: 'tsconfig.app.json',
18+
assets: [
19+
'src/favicon.ico',
20+
'src/assets',
21+
],
22+
'styles': [
23+
'src/styles.css',
24+
],
25+
'scripts': [],
26+
};
27+
const browserConfigs = appArchitect['build'].configurations;
28+
browserConfigs['production'] = {
29+
extractCss: true,
30+
};
31+
browserConfigs['one'] = {
32+
assets: [],
33+
};
34+
browserConfigs['two'] = {
35+
sourceMap: false,
36+
};
37+
browserConfigs['three'] = {
38+
extractCss: false, // Defaults to false when not set.
39+
};
40+
});
41+
42+
// Test the base configuration.
43+
await ng('build');
44+
await expectFileToExist('dist/test-project/favicon.ico');
45+
await expectFileToExist('dist/test-project/main-es2015.js.map');
46+
await expectFileToExist('dist/test-project/styles-es2015.js');
47+
await expectFileToExist('dist/test-project/vendor-es2015.js');
48+
// Test that --prod extracts css.
49+
await ng('build', '--prod');
50+
await expectFileToExist('dist/test-project/styles.css');
51+
// But using a config overrides prod.
52+
await ng('build', '--prod', '--configuration=three');
53+
await expectFileToExist('dist/test-project/styles-es2015.js');
54+
await expectToFail(() => expectFileToExist('dist/test-project/styles.css'));
55+
// Use two configurations.
56+
await ng('build', '--configuration=one,two', '--vendor-chunk=false');
57+
await expectToFail(() => expectFileToExist('dist/test-project/favicon.ico'));
58+
await expectToFail(() => expectFileToExist('dist/test-project/main-es2015.js.map'));
59+
// Use two configurations and two overrides, one of which overrides a config.
60+
await ng('build', '--configuration=one,two', '--vendor-chunk=false', '--sourceMap=true');
61+
await expectToFail(() => expectFileToExist('dist/test-project/favicon.ico'));
62+
await expectFileToExist('dist/test-project/main-es2015.js.map');
63+
await expectToFail(() => expectFileToExist('dist/test-project/vendor-es2015.js'));
64+
// Use three configurations and a override, and prod at the end.
65+
await ng('build', '--configuration=one,two,three', '--vendor-chunk=false', '--prod');
66+
await expectToFail(() => expectFileToExist('dist/test-project/favicon.ico'));
67+
await expectToFail(() => expectFileToExist('dist/test-project/main-es2015.js.map'));
68+
await expectToFail(() => expectFileToExist('dist/test-project/vendor-es2015.js'));
69+
await expectFileToExist('dist/test-project/styles-es2015.js');
70+
await expectToFail(() => expectFileToExist('dist/test-project/styles.css'));
71+
}

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.