Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): don't process stylesheets in extr…
Browse files Browse the repository at this point in the history
…action 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.
  • Loading branch information
alan-agius4 committed Sep 30, 2020
1 parent e96fbd3 commit dcad2ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
@@ -0,0 +1 @@
export default '';
20 changes: 12 additions & 8 deletions packages/angular_devkit/build_angular/src/extract-i18n/index.ts
Expand Up @@ -22,12 +22,7 @@ import { ExecutionTransformer } from '../transforms';
import { createI18nOptions } from '../utils/i18n-options';
import { assertCompatibleAngularVersion } from '../utils/version';
import { generateBrowserWebpackConfigFromContext } from '../utils/webpack-browser-config';
import {
getAotConfig,
getCommonConfig,
getStatsConfig,
getStylesConfig,
} from '../webpack/configs';
import { getAotConfig, getCommonConfig, getStatsConfig } from '../webpack/configs';
import { createWebpackLoggingCallback } from '../webpack/utils/stats';
import { Format, Schema } from './schema';

Expand Down Expand Up @@ -182,7 +177,6 @@ export async function execute(
getCommonConfig(wco),
// Only use VE extraction if not using Ivy
getAotConfig(wco, !usingIvy),
getStylesConfig(wco),
getStatsConfig(wco),
];

Expand All @@ -203,6 +197,16 @@ export async function execute(
});
}

// Replace all stylesheets with an empty default export
partials.push({
plugins: [
new webpack.NormalModuleReplacementPlugin(
/\.(css|scss|sass|styl|less)$/,
path.join(__dirname, 'empty-export-default.js'),
),
],
});

return partials;
},
);
Expand All @@ -227,7 +231,7 @@ export async function execute(
context,
{
logging: createWebpackLoggingCallback(false, context.logger),
webpackFactory: await import('webpack'),
webpackFactory: webpack,
},
).toPromise();

Expand Down

0 comments on commit dcad2ee

Please sign in to comment.