@@ -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 { addFileReplacements , normalizeAssetPatterns } 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
@@ -151,7 +152,18 @@ export class BrowserBuilder implements Builder<BrowserBuilderSchema> {
151
152
webpackConfigs . push ( typescriptConfigPartial ) ;
152
153
}
153
154
154
- return webpackMerge ( webpackConfigs ) ;
155
+ const webpackConfig = webpackMerge ( webpackConfigs ) ;
156
+
157
+ if ( options . profile ) {
158
+ const smp = new SpeedMeasurePlugin ( {
159
+ outputFormat : 'json' ,
160
+ outputTarget : getSystemPath ( join ( root , 'speed-measure-plugin.json' ) ) ,
161
+ } ) ;
162
+
163
+ return smp . wrap ( webpackConfig ) ;
164
+ }
165
+
166
+ return webpackConfig ;
155
167
}
156
168
157
169
private _deleteOutputDir ( root : Path , outputPath : Path , host : virtualFs . Host ) {
0 commit comments