Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,8 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
safari10: true,
output: {
ecma: terserEcma,
comments: false,
// default behavior (undefined value) is to keep only important comments (licenses, etc.)
comments: !buildOptions.extractLicenses && undefined,
webkit: true,
},
// On server, we don't want to compress anything. We still set the ngDevMode = false for it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ describe('Browser Builder bundle budgets', () => {
it(`when 'bundle' budget`, async () => {
const overrides = {
optimization: true,
extractLicenses: true,
budgets: [{ type: 'bundle', name: 'main', maximumError: '3Kb' }],
};

Expand Down
25 changes: 16 additions & 9 deletions tests/legacy-cli/e2e/tests/build/extract-licenses.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import {join} from 'path';
import {expectFileToExist} from '../../utils/fs';
import {expectToFail} from '../../utils/utils';
import {ng} from '../../utils/process';
import { expectFileToExist, expectFileToMatch } from '../../utils/fs';
import { ng } from '../../utils/process';
import { expectToFail } from '../../utils/utils';

export default function() {
// TODO(architect): Delete this test. It is now in devkit/build-angular.
export default async function() {
// Licenses should be left intact if extraction is disabled
await ng('build', '--prod', '--extract-licenses=false', '--output-hashing=none');

return ng('build', '--prod', '--extract-licenses=false')
.then(() => expectFileToExist(join(process.cwd(), 'dist')))
.then(() => expectToFail(() => expectFileToExist('dist/test-project/3rdpartylicenses.txt')));
await expectToFail(() => expectFileToExist('dist/test-project/3rdpartylicenses.txt'));
await expectFileToMatch('dist/test-project/main-es2015.js', '@license');
await expectFileToMatch('dist/test-project/main-es5.js', '@license');

// Licenses should be removed if extraction is enabled
await ng('build', '--prod', '--extract-licenses', '--output-hashing=none');

await expectFileToExist('dist/test-project/3rdpartylicenses.txt');
await expectToFail(() => expectFileToMatch('dist/test-project/main-es2015.js', '@license'));
await expectToFail(() => expectFileToMatch('dist/test-project/main-es5.js', '@license'));
}