Skip to content

Commit 49a120b

Browse files
authored
fix(build): use config output path as default (#2158)
1 parent bda7cd2 commit 49a120b

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

packages/angular-cli/commands/build.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ const BuildCommand = Command.extend({
2525
aliases: ['t', { 'dev': 'development' }, { 'prod': 'production' }]
2626
},
2727
{ name: 'environment', type: String, default: '', aliases: ['e'] },
28-
{ name: 'output-path', type: 'Path', default: 'dist/', aliases: ['o'] },
29-
{ name: 'watch', type: Boolean, default: false, aliases: ['w'] },
28+
{ name: 'output-path', type: 'Path', default: null, aliases: ['o'] },
29+
{ name: 'watch', type: Boolean, default: false, aliases: ['w'] },
3030
{ name: 'watcher', type: String },
3131
{ name: 'suppress-sizes', type: Boolean, default: false },
3232
{ name: 'base-href', type: String, default: null, aliases: ['bh'] },

packages/angular-cli/commands/serve.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export interface ServeTaskOptions {
2222
liveReloadLiveCss?: boolean;
2323
target?: string;
2424
environment?: string;
25-
outputPath?: string;
2625
ssl?: boolean;
2726
sslKey?: string;
2827
sslCert?: string;

packages/angular-cli/tasks/build-webpack.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,24 @@ import * as webpack from 'webpack';
55
import { BuildOptions } from '../commands/build';
66
import { NgCliWebpackConfig } from '../models/webpack-config';
77
import { webpackOutputOptions } from '../models/';
8+
import { CliConfig } from '../models/config';
89

910
// Configure build and output;
1011
let lastHash: any = null;
1112

1213
export default <any>Task.extend({
13-
// Options: String outputPath
1414
run: function (runTaskOptions: BuildOptions) {
1515

1616
const project = this.cliProject;
1717

18-
rimraf.sync(path.resolve(project.root, runTaskOptions.outputPath));
18+
const outputDir = runTaskOptions.outputPath || CliConfig.fromProject().config.apps[0].outDir;
19+
rimraf.sync(path.resolve(project.root, outputDir));
20+
1921
const config = new NgCliWebpackConfig(
2022
project,
2123
runTaskOptions.target,
2224
runTaskOptions.environment,
23-
runTaskOptions.outputPath,
25+
outputDir,
2426
runTaskOptions.baseHref
2527
).config;
2628

tests/e2e/tests/build/output-dir.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,20 @@ import {ng} from '../../utils/process';
22
import {expectFileToExist} from '../../utils/fs';
33
import {expectToFail} from '../../utils/utils';
44
import {expectGitToBeClean} from '../../utils/git';
5+
import {updateJsonFile} from '../../utils/project';
56

67

78
export default function() {
89
return ng('build', '-o', './build-output')
910
.then(() => expectFileToExist('./build-output/index.html'))
1011
.then(() => expectFileToExist('./build-output/main.bundle.js'))
12+
.then(() => expectToFail(expectGitToBeClean))
13+
.then(() => updateJsonFile('angular-cli.json', configJson => {
14+
const app = configJson['apps'][0];
15+
app['outDir'] = 'config-build-output';
16+
}))
17+
.then(() => ng('build'))
18+
.then(() => expectFileToExist('./config-build-output/index.html'))
19+
.then(() => expectFileToExist('./config-build-output/main.bundle.js'))
1120
.then(() => expectToFail(expectGitToBeClean));
1221
}

0 commit comments

Comments
 (0)