Skip to content

Commit dcad2ee

Browse files
committed
fix(@angular-devkit/build-angular): don't process stylesheets in extraction builder
When building an application for i18n extraction we are currently redundantly processing components stylesheets. With this change we replace the components stylesheets with an empty string which helps reduce the i18n build time.
1 parent e96fbd3 commit dcad2ee

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default '';

packages/angular_devkit/build_angular/src/extract-i18n/index.ts

+12-8
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,7 @@ import { ExecutionTransformer } from '../transforms';
2222
import { createI18nOptions } from '../utils/i18n-options';
2323
import { assertCompatibleAngularVersion } from '../utils/version';
2424
import { generateBrowserWebpackConfigFromContext } from '../utils/webpack-browser-config';
25-
import {
26-
getAotConfig,
27-
getCommonConfig,
28-
getStatsConfig,
29-
getStylesConfig,
30-
} from '../webpack/configs';
25+
import { getAotConfig, getCommonConfig, getStatsConfig } from '../webpack/configs';
3126
import { createWebpackLoggingCallback } from '../webpack/utils/stats';
3227
import { Format, Schema } from './schema';
3328

@@ -182,7 +177,6 @@ export async function execute(
182177
getCommonConfig(wco),
183178
// Only use VE extraction if not using Ivy
184179
getAotConfig(wco, !usingIvy),
185-
getStylesConfig(wco),
186180
getStatsConfig(wco),
187181
];
188182

@@ -203,6 +197,16 @@ export async function execute(
203197
});
204198
}
205199

200+
// Replace all stylesheets with an empty default export
201+
partials.push({
202+
plugins: [
203+
new webpack.NormalModuleReplacementPlugin(
204+
/\.(css|scss|sass|styl|less)$/,
205+
path.join(__dirname, 'empty-export-default.js'),
206+
),
207+
],
208+
});
209+
206210
return partials;
207211
},
208212
);
@@ -227,7 +231,7 @@ export async function execute(
227231
context,
228232
{
229233
logging: createWebpackLoggingCallback(false, context.logger),
230-
webpackFactory: await import('webpack'),
234+
webpackFactory: webpack,
231235
},
232236
).toPromise();
233237

0 commit comments

Comments
 (0)