Skip to content

Commit 850954a

Browse files
committed
fix(@angular-devkit/build-angular): warn when components styles sourcemaps are not generated when styles optimization is enabled
With this change we add a warning to inform the users that sourcemaps are not generated when both styles sourcemaps and optimization are enabled. This is because component style sourcemaps are inline which would drastically increase the bundle size. Closes #22834
1 parent 774e83d commit 850954a

File tree

1 file changed

+8
-2
lines changed
  • packages/angular_devkit/build_angular/src/webpack/configs

1 file changed

+8
-2
lines changed

packages/angular_devkit/build_angular/src/webpack/configs/styles.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import {
3535

3636
// eslint-disable-next-line max-lines-per-function
3737
export function getStylesConfig(wco: WebpackConfigOptions): Configuration {
38-
const { root, buildOptions } = wco;
38+
const { root, buildOptions, logger } = wco;
3939
const extraPlugins: Configuration['plugins'] = [];
4040

4141
extraPlugins.push(new AnyComponentStyleBudgetChecker(buildOptions.budgets));
@@ -93,7 +93,7 @@ export function getStylesConfig(wco: WebpackConfigOptions): Configuration {
9393
tailwindPackagePath = require.resolve('tailwindcss', { paths: [wco.root] });
9494
} catch {
9595
const relativeTailwindConfigPath = path.relative(wco.root, tailwindConfigPath);
96-
wco.logger.warn(
96+
logger.warn(
9797
`Tailwind CSS configuration file found (${relativeTailwindConfigPath})` +
9898
` but the 'tailwindcss' package is not installed.` +
9999
` To enable Tailwind CSS, please install the 'tailwindcss' package.`,
@@ -148,6 +148,12 @@ export function getStylesConfig(wco: WebpackConfigOptions): Configuration {
148148
!buildOptions.sourceMap.hidden
149149
);
150150

151+
if (!componentsSourceMap && cssSourceMap) {
152+
logger.warn(
153+
'Components styles sourcemaps are not generated when styles optimization is enabled.',
154+
);
155+
}
156+
151157
// extract global css from js files into own css file.
152158
extraPlugins.push(new MiniCssExtractPlugin({ filename: `[name]${hashFormat.extract}.css` }));
153159

0 commit comments

Comments
 (0)