@@ -12,7 +12,7 @@ import {
12
12
BuilderContext ,
13
13
} from '@angular-devkit/architect' ;
14
14
import { LoggingCallback , WebpackBuilder } from '@angular-devkit/build-webpack' ;
15
- import { Path , getSystemPath , normalize , resolve , virtualFs } from '@angular-devkit/core' ;
15
+ import { Path , getSystemPath , join , normalize , resolve , virtualFs } from '@angular-devkit/core' ;
16
16
import * as fs from 'fs' ;
17
17
import { Observable , concat , of , throwError } from 'rxjs' ;
18
18
import { concatMap , last , tap } from 'rxjs/operators' ;
@@ -36,6 +36,7 @@ import {
36
36
} from '../angular-cli-files/utilities/stats' ;
37
37
import { defaultProgress , normalizeAssetPatterns , normalizeFileReplacements } from '../utils' ;
38
38
import { AssetPatternObject , BrowserBuilderSchema , CurrentFileReplacement } from './schema' ;
39
+ const SpeedMeasurePlugin = require ( 'speed-measure-webpack-plugin' ) ;
39
40
const webpackMerge = require ( 'webpack-merge' ) ;
40
41
41
42
@@ -154,7 +155,18 @@ export class BrowserBuilder implements Builder<BrowserBuilderSchema> {
154
155
webpackConfigs . push ( typescriptConfigPartial ) ;
155
156
}
156
157
157
- return webpackMerge ( webpackConfigs ) ;
158
+ const webpackConfig = webpackMerge ( webpackConfigs ) ;
159
+
160
+ if ( options . profile ) {
161
+ const smp = new SpeedMeasurePlugin ( {
162
+ outputFormat : 'json' ,
163
+ outputTarget : getSystemPath ( join ( root , 'speed-measure-plugin.json' ) ) ,
164
+ } ) ;
165
+
166
+ return smp . wrap ( webpackConfig ) ;
167
+ }
168
+
169
+ return webpackConfig ;
158
170
}
159
171
160
172
private _deleteOutputDir ( root : Path , outputPath : Path , host : virtualFs . Host ) {
0 commit comments