Skip to content

Commit da1c197

Browse files
clydinhansl
authored andcommitted
feat(build): disable sourcemaps for production (angular#3963)
sourcemaps can be enabled using the `--sourcemap` option, if desired
1 parent 224250c commit da1c197

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

packages/angular-cli/commands/build.run.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,15 @@ export default function buildRun(commandOptions: BuildOptions) {
2222
}
2323
}
2424

25+
if (typeof commandOptions.sourcemap === 'undefined') {
26+
if (commandOptions.target == 'development') {
27+
commandOptions.sourcemap = true;
28+
}
29+
if (commandOptions.target == 'production') {
30+
commandOptions.sourcemap = false;
31+
}
32+
}
33+
2534
const project = this.project;
2635

2736
// Check angular version.

packages/angular-cli/commands/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const BuildCommand = Command.extend({
3939
{ name: 'suppress-sizes', type: Boolean, default: false },
4040
{ name: 'base-href', type: String, default: null, aliases: ['bh'] },
4141
{ name: 'aot', type: Boolean, default: false },
42-
{ name: 'sourcemap', type: Boolean, default: true, aliases: ['sm'] },
42+
{ name: 'sourcemap', type: Boolean, aliases: ['sm'] },
4343
{ name: 'vendor-chunk', type: Boolean, default: true },
4444
{ name: 'verbose', type: Boolean, default: false },
4545
{ name: 'progress', type: Boolean, default: true },

tests/e2e/tests/build/sourcemap.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ import {expectToFail} from '../../utils/utils';
66
export default function() {
77
return ng('build')
88
.then(() => expectFileToExist('dist/main.bundle.map'))
9+
910
.then(() => ng('build', '--no-sourcemap'))
10-
.then(() => expectToFail(() => expectFileToExist('dist/main.bundle.map')));
11+
.then(() => expectToFail(() => expectFileToExist('dist/main.bundle.map')))
12+
13+
.then(() => ng('build', '--prod', '--output-hashing=none'))
14+
.then(() => expectToFail(() => expectFileToExist('dist/main.bundle.map')))
15+
16+
.then(() => ng('build', '--prod', '--output-hashing=none', '--sourcemap'))
17+
.then(() => expectFileToExist('dist/main.bundle.map'));
1118
}

0 commit comments

Comments
 (0)