Skip to content

Commit c58f0ee

Browse files
alan-agius4mgechev
authored andcommitted
fix(@angular-devkit/build-angular): remove certain redundant build steps from second build in differential loading
With this change we remove styles compilation and copying of assets for the second build when differential loading is enabled. This should improve the build times for larger applications.
1 parent 8939ab7 commit c58f0ee

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

packages/angular_devkit/build_angular/src/utils/webpack-browser-config.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,30 @@ export async function generateWebpackConfig(
6868
// For differential loading, we can have several targets
6969
return scriptTargets.map(scriptTarget => {
7070
let buildOptions: NormalizedBrowserBuilderSchema = { ...options };
71+
const supportES2015
72+
= scriptTarget !== ts.ScriptTarget.ES3 && scriptTarget !== ts.ScriptTarget.ES5;
73+
7174
if (differentialLoading) {
72-
// For differential loading, the builder needs to created the index.html by itself
73-
// without using a webpack plugin.
7475
buildOptions = {
7576
...options,
77+
...(
78+
// FIXME: we do create better webpack config composition to achieve the below
79+
// When DL is enabled and supportES2015 is true it means that we are on the second build
80+
// This also means that we don't need to include styles and assets multiple times
81+
supportES2015
82+
? {}
83+
: {
84+
styles: options.extractCss ? [] : options.styles,
85+
assets: [],
86+
}
87+
),
7688
es5BrowserSupport: undefined,
7789
index: '',
7890
esVersionInFileName: true,
7991
scriptTargetOverride: scriptTarget,
8092
};
8193
}
8294

83-
const supportES2015
84-
= scriptTarget !== ts.ScriptTarget.ES3 && scriptTarget !== ts.ScriptTarget.ES5;
85-
8695
const wco: BrowserWebpackConfigOptions = {
8796
root: workspaceRoot,
8897
logger: logger.createChild('webpackConfigOptions'),

0 commit comments

Comments
 (0)