From fef3b1543caa831098a4075938cb3f13fe8a66fe Mon Sep 17 00:00:00 2001 From: Filipe Silva Date: Mon, 24 Oct 2016 16:10:56 +0100 Subject: [PATCH] feat(build): add --profile flag Currently builds always output profiling information by default. This PR adds a flag to enable it, defaulting to false. --- packages/angular-cli/commands/build.ts | 4 +++- packages/angular-cli/commands/serve.ts | 2 ++ packages/angular-cli/tasks/build-webpack-watch.ts | 2 +- packages/angular-cli/tasks/build-webpack.ts | 7 +++---- packages/angular-cli/tasks/serve-webpack.ts | 2 +- 5 files changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/angular-cli/commands/build.ts b/packages/angular-cli/commands/build.ts index 744b405fe567..23d24f8e80f9 100644 --- a/packages/angular-cli/commands/build.ts +++ b/packages/angular-cli/commands/build.ts @@ -11,6 +11,7 @@ export interface BuildOptions { supressSizes: boolean; baseHref?: string; aot?: boolean; + profile?: boolean; } const BuildCommand = Command.extend({ @@ -31,7 +32,8 @@ const BuildCommand = Command.extend({ { name: 'watcher', type: String }, { name: 'suppress-sizes', type: Boolean, default: false }, { name: 'base-href', type: String, default: null, aliases: ['bh'] }, - { name: 'aot', type: Boolean, default: false } + { name: 'aot', type: Boolean, default: false }, + { name: 'profile', type: Boolean, default: false } ], run: function (commandOptions: BuildOptions) { diff --git a/packages/angular-cli/commands/serve.ts b/packages/angular-cli/commands/serve.ts index 7c16c49993b8..4a33d68bd5ee 100644 --- a/packages/angular-cli/commands/serve.ts +++ b/packages/angular-cli/commands/serve.ts @@ -26,6 +26,7 @@ export interface ServeTaskOptions { sslKey?: string; sslCert?: string; aot?: boolean; + profile?: boolean; open?: boolean; } @@ -81,6 +82,7 @@ const ServeCommand = Command.extend({ { name: 'ssl-key', type: String, default: 'ssl/server.key' }, { name: 'ssl-cert', type: String, default: 'ssl/server.crt' }, { name: 'aot', type: Boolean, default: false }, + { name: 'profile', type: Boolean, default: false }, { name: 'open', type: Boolean, diff --git a/packages/angular-cli/tasks/build-webpack-watch.ts b/packages/angular-cli/tasks/build-webpack-watch.ts index 700c977298e4..7e004fc6ddba 100644 --- a/packages/angular-cli/tasks/build-webpack-watch.ts +++ b/packages/angular-cli/tasks/build-webpack-watch.ts @@ -29,7 +29,7 @@ export default Task.extend({ const webpackCompiler: any = webpack(config); webpackCompiler.apply(new ProgressPlugin({ - profile: true + profile: runTaskOptions.profile })); return new Promise((resolve, reject) => { diff --git a/packages/angular-cli/tasks/build-webpack.ts b/packages/angular-cli/tasks/build-webpack.ts index 80fc0b9e62a5..619dfe2847d3 100644 --- a/packages/angular-cli/tasks/build-webpack.ts +++ b/packages/angular-cli/tasks/build-webpack.ts @@ -1,7 +1,8 @@ import * as rimraf from 'rimraf'; import * as path from 'path'; -const Task = require('ember-cli/lib/models/task'); import * as webpack from 'webpack'; +const Task = require('ember-cli/lib/models/task'); +const ProgressPlugin = require('webpack/lib/ProgressPlugin'); import { BuildOptions } from '../commands/build'; import { NgCliWebpackConfig } from '../models/webpack-config'; import { webpackOutputOptions } from '../models/'; @@ -31,10 +32,8 @@ export default Task.extend({ const webpackCompiler: any = webpack(config); - const ProgressPlugin = require('webpack/lib/ProgressPlugin'); - webpackCompiler.apply(new ProgressPlugin({ - profile: true + profile: runTaskOptions.profile })); return new Promise((resolve, reject) => { diff --git a/packages/angular-cli/tasks/serve-webpack.ts b/packages/angular-cli/tasks/serve-webpack.ts index 9c2e0a6229ad..2d875d8c6c96 100644 --- a/packages/angular-cli/tasks/serve-webpack.ts +++ b/packages/angular-cli/tasks/serve-webpack.ts @@ -37,7 +37,7 @@ export default Task.extend({ webpackCompiler = webpack(config); webpackCompiler.apply(new ProgressPlugin({ - profile: true, + profile: commandOptions.profile, colors: true }));