Skip to content

Commit

Permalink
fix(build): use config output path as default (angular#2158)
Browse files Browse the repository at this point in the history
  • Loading branch information
filipesilva authored and Jonathan Jayet committed Oct 2, 2016
1 parent e8a5185 commit 32839bb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/angular-cli/commands/build.ts
Expand Up @@ -25,8 +25,8 @@ const BuildCommand = Command.extend({
aliases: ['t', { 'dev': 'development' }, { 'prod': 'production' }]
},
{ name: 'environment', type: String, default: '', aliases: ['e'] },
{ name: 'output-path', type: 'Path', default: 'dist/', aliases: ['o'] },
{ name: 'watch', type: Boolean, default: false, aliases: ['w'] },
{ name: 'output-path', type: 'Path', default: null, aliases: ['o'] },
{ name: 'watch', type: Boolean, default: false, aliases: ['w'] },
{ name: 'watcher', type: String },
{ name: 'suppress-sizes', type: Boolean, default: false },
{ name: 'base-href', type: String, default: null, aliases: ['bh'] },
Expand Down
1 change: 0 additions & 1 deletion packages/angular-cli/commands/serve.ts
Expand Up @@ -22,7 +22,6 @@ export interface ServeTaskOptions {
liveReloadLiveCss?: boolean;
target?: string;
environment?: string;
outputPath?: string;
ssl?: boolean;
sslKey?: string;
sslCert?: string;
Expand Down
8 changes: 5 additions & 3 deletions packages/angular-cli/tasks/build-webpack.ts
Expand Up @@ -5,22 +5,24 @@ import * as webpack from 'webpack';
import { BuildOptions } from '../commands/build';
import { NgCliWebpackConfig } from '../models/webpack-config';
import { webpackOutputOptions } from '../models/';
import { CliConfig } from '../models/config';

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

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

const project = this.cliProject;

rimraf.sync(path.resolve(project.root, runTaskOptions.outputPath));
const outputDir = runTaskOptions.outputPath || CliConfig.fromProject().config.apps[0].outDir;
rimraf.sync(path.resolve(project.root, outputDir));

const config = new NgCliWebpackConfig(
project,
runTaskOptions.target,
runTaskOptions.environment,
runTaskOptions.outputPath,
outputDir,
runTaskOptions.baseHref
).config;

Expand Down
9 changes: 9 additions & 0 deletions tests/e2e/tests/build/output-dir.ts
Expand Up @@ -2,11 +2,20 @@ import {ng} from '../../utils/process';
import {expectFileToExist} from '../../utils/fs';
import {expectToFail} from '../../utils/utils';
import {expectGitToBeClean} from '../../utils/git';
import {updateJsonFile} from '../../utils/project';


export default function() {
return ng('build', '-o', './build-output')
.then(() => expectFileToExist('./build-output/index.html'))
.then(() => expectFileToExist('./build-output/main.bundle.js'))
.then(() => expectToFail(expectGitToBeClean))
.then(() => updateJsonFile('angular-cli.json', configJson => {
const app = configJson['apps'][0];
app['outDir'] = 'config-build-output';
}))
.then(() => ng('build'))
.then(() => expectFileToExist('./config-build-output/index.html'))
.then(() => expectFileToExist('./config-build-output/main.bundle.js'))
.then(() => expectToFail(expectGitToBeClean));
}

0 comments on commit 32839bb

Please sign in to comment.