From 99f7e3340595285cfd1bb053946b3411bc563405 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sun, 8 Dec 2024 18:02:27 +0530 Subject: [PATCH 1/3] docs(module): add `module.parser.css.import` option --- src/content/configuration/module.mdx | 63 +++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/src/content/configuration/module.mdx b/src/content/configuration/module.mdx index 17fd3e33e7f5..47b65dcea234 100644 --- a/src/content/configuration/module.mdx +++ b/src/content/configuration/module.mdx @@ -262,6 +262,9 @@ module.exports = { css: { // Parser options for css modules + // Enable/disable `@import` at-rules handling, available since webpack 5.97.0 + // type: boolean + import: true, // Use ES modules named export for css exports, available since webpack 5.90.0 // type: boolean namedExports: true, @@ -281,9 +284,65 @@ module.exports = { }; ``` -### module.parser.css.namedExports +### module.parser.css + +Configure options for the CSS parser. + +```js +module.exports = { + module: { + parser: { + css: { + // ... + namedExports: true, + }, + }, + }, +}; +``` + +#### module.parser.css.import + +This option enables the handling of `@import` at-rules in CSS files. When set to `true`, `@import` statements are processed, allowing modular inclusion of styles from other CSS files. + +- Type: `boolean` +- Available: 5.97.0+ +- Example: + + ```js + module.exports = { + module: { + parser: { + css: { + import: true, + }, + }, + }, + }; + ``` + + ```css + /* reset-styles.css */ + body { + margin: 0; + padding: 0; + } + ``` + + ```css + /* styles.css */ + @import './reset-styles.css'; + + body { + background-color: red; + } + ``` + +T> Filtering of `@import` rules, as [supported by css-loader](/loaders/css-loader/#filter), is not supported in the parser. + +#### module.parser.css.namedExports -This option enables the use of ES modules named export for CSS exports. When set to true, the CSS module will export its classes and styles using named exports. +This option enables the use of ES modules named export for CSS exports. When set to `true`, the CSS module will export its classes and styles using named exports. - Type: `boolean` - Available: 5.90.0+ From 2ae65ff3cba86e4b5d30f9dc9e46bddfec9115d9 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Sun, 8 Dec 2024 18:07:29 +0530 Subject: [PATCH 2/3] docs: udpate note --- src/content/configuration/module.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/configuration/module.mdx b/src/content/configuration/module.mdx index 47b65dcea234..4a4ab916153d 100644 --- a/src/content/configuration/module.mdx +++ b/src/content/configuration/module.mdx @@ -338,7 +338,7 @@ This option enables the handling of `@import` at-rules in CSS files. When set to } ``` -T> Filtering of `@import` rules, as [supported by css-loader](/loaders/css-loader/#filter), is not supported in the parser. +T> To filter specific imports, you can use Webpack's built-in [IgnorePlugin](plugins/ignore-plugin/). The [`filter` option](/loaders/css-loader/#filter), as available in `css-loader`, is not supported. #### module.parser.css.namedExports From 709136680a91d9e6f745433a71a7ef41303089c5 Mon Sep 17 00:00:00 2001 From: Nitin Kumar Date: Mon, 9 Dec 2024 10:33:05 +0530 Subject: [PATCH 3/3] Update src/content/configuration/module.mdx --- src/content/configuration/module.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/content/configuration/module.mdx b/src/content/configuration/module.mdx index 4a4ab916153d..869d9a54be0e 100644 --- a/src/content/configuration/module.mdx +++ b/src/content/configuration/module.mdx @@ -338,7 +338,7 @@ This option enables the handling of `@import` at-rules in CSS files. When set to } ``` -T> To filter specific imports, you can use Webpack's built-in [IgnorePlugin](plugins/ignore-plugin/). The [`filter` option](/loaders/css-loader/#filter), as available in `css-loader`, is not supported. +T> To filter specific imports, you can use Webpack's built-in [IgnorePlugin](/plugins/ignore-plugin/). The [`filter` option](/loaders/css-loader/#filter), as available in `css-loader`, is not supported. #### module.parser.css.namedExports