@@ -36,11 +36,13 @@ import {
36
36
cachingDisabled ,
37
37
shouldBeautify ,
38
38
} from '../../../utils/environment-options' ;
39
- import { BundleBudgetPlugin } from '../../plugins/bundle-budget' ;
40
- import { NamedLazyChunksPlugin } from '../../plugins/named-chunks-plugin' ;
41
- import { OptimizeCssWebpackPlugin } from '../../plugins/optimize-css-webpack-plugin' ;
42
- import { ScriptsWebpackPlugin } from '../../plugins/scripts-webpack-plugin' ;
43
- import { WebpackRollupLoader } from '../../plugins/webpack' ;
39
+ import {
40
+ BundleBudgetPlugin ,
41
+ NamedLazyChunksPlugin ,
42
+ OptimizeCssWebpackPlugin ,
43
+ ScriptsWebpackPlugin ,
44
+ WebpackRollupLoader ,
45
+ } from '../../plugins/webpack' ;
44
46
import { findAllNodeModules } from '../../utilities/find-up' ;
45
47
import { WebpackConfigOptions } from '../build-options' ;
46
48
import { getEsVersionForFileName , getOutputHashFormat , normalizeExtraEntryPoints } from './utils' ;
@@ -149,7 +151,7 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
149
151
// tslint:disable-next-line: no-any
150
152
( compilation . mainTemplate . hooks as any ) . assetPath . tap (
151
153
'build-angular' ,
152
- ( filename : string | ( ( data : ChunkData ) => string ) , data : ChunkData ) => {
154
+ ( filename : string | ( ( data : ChunkData ) => string ) , data : ChunkData ) => {
153
155
const assetName = typeof filename === 'function' ? filename ( data ) : filename ;
154
156
const isMap = assetName && assetName . endsWith ( '.map' ) ;
155
157
@@ -313,6 +315,12 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
313
315
extraPlugins . push ( new NamedLazyChunksPlugin ( ) ) ;
314
316
}
315
317
318
+ if ( ! differentialLoadingMode ) {
319
+ // Budgets are computed after differential builds, not via a plugin.
320
+ // https://github.com/angular/angular-cli/blob/master/packages/angular_devkit/build_angular/src/browser/index.ts
321
+ extraPlugins . push ( new BundleBudgetPlugin ( { budgets : buildOptions . budgets } ) ) ;
322
+ }
323
+
316
324
let sourceMapUseRule ;
317
325
if ( ( scriptsSourceMap || stylesSourceMap ) && vendorSourceMap ) {
318
326
sourceMapUseRule = {
@@ -411,18 +419,18 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
411
419
allowMinify &&
412
420
( buildOptions . platform == 'server'
413
421
? {
414
- ecma : terserEcma ,
415
- global_defs : angularGlobalDefinitions ,
416
- keep_fnames : true ,
417
- }
422
+ ecma : terserEcma ,
423
+ global_defs : angularGlobalDefinitions ,
424
+ keep_fnames : true ,
425
+ }
418
426
: {
419
- ecma : terserEcma ,
420
- pure_getters : buildOptions . buildOptimizer ,
421
- // PURE comments work best with 3 passes.
422
- // See https://github.com/webpack/webpack/issues/2899#issuecomment-317425926.
423
- passes : buildOptions . buildOptimizer ? 3 : 1 ,
424
- global_defs : angularGlobalDefinitions ,
425
- } ) ,
427
+ ecma : terserEcma ,
428
+ pure_getters : buildOptions . buildOptimizer ,
429
+ // PURE comments work best with 3 passes.
430
+ // See https://github.com/webpack/webpack/issues/2899#issuecomment-317425926.
431
+ passes : buildOptions . buildOptimizer ? 3 : 1 ,
432
+ global_defs : angularGlobalDefinitions ,
433
+ } ) ,
426
434
// We also want to avoid mangling on server.
427
435
// Name mangling is handled within the browser builder
428
436
mangle : allowMangle && buildOptions . platform !== 'server' && ! differentialLoadingMode ,
@@ -543,13 +551,7 @@ export function getCommonConfig(wco: WebpackConfigOptions): Configuration {
543
551
minimizer : [
544
552
new HashedModuleIdsPlugin ( ) ,
545
553
...extraMinimizers ,
546
- ] . concat ( differentialLoadingMode ? [
547
- // Budgets are computed after differential builds, not via a plugin.
548
- // https://github.com/angular/angular-cli/blob/master/packages/angular_devkit/build_angular/src/browser/index.ts
549
- ] : [
550
- // Non differential builds should be computed here, as a plugin.
551
- new BundleBudgetPlugin ( { budgets : buildOptions . budgets } ) ,
552
- ] ) ,
554
+ ] ,
553
555
} ,
554
556
plugins : [
555
557
// Always replace the context for the System.import in angular/core to prevent warnings.
0 commit comments