Skip to content

Commit f1d2873

Browse files
alan-agius4dgp1130
authored andcommitted
fix(@angular-devkit/build-angular): only extract CSS styles when are specified in styles option
This fixes an issue were in some cases when importing CSS in the compilation using import syntax caused CSS to be extracted which causes a runtime error. In general this is not something that we fully support since this is a specific webpack features and importing CSS as if they were ES modules not supported by the browsers. However, certain widely using libraries such as Monaco editor depend on this specific Webpack feature. Note: This non-standard unsupported behaviour will no longer be possible in the next major version. Closes #22358
1 parent ddec41e commit f1d2873

File tree

1 file changed

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

1 file changed

+6
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -377,17 +377,17 @@ export function getStylesConfig(wco: WebpackConfigOptions): Configuration {
377377
// Setup processing rules for global and component styles
378378
{
379379
oneOf: [
380-
// Component styles are all styles except defined global styles
381-
{
382-
use: componentStyleLoaders,
383-
resourceQuery: /\?ngResource/,
384-
type: 'asset/source',
385-
},
386380
// Global styles are only defined global styles
387381
{
388382
use: globalStyleLoaders,
383+
include: globalStylePaths,
389384
resourceQuery: { not: [/\?ngResource/] },
390385
},
386+
// Component styles are all styles except defined global styles
387+
{
388+
use: componentStyleLoaders,
389+
type: 'asset/source',
390+
},
391391
],
392392
},
393393
{ use },

0 commit comments

Comments
 (0)