Skip to content

Commit 86ae32b

Browse files
authored
docs(module): add module.parser.css.import option (#7490)
1 parent bf76271 commit 86ae32b

File tree

1 file changed

+61
-2
lines changed

1 file changed

+61
-2
lines changed

src/content/configuration/module.mdx

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,9 @@ module.exports = {
262262
css: {
263263
// Parser options for css modules
264264

265+
// Enable/disable `@import` at-rules handling, available since webpack 5.97.0
266+
// type: boolean
267+
import: true,
265268
// Use ES modules named export for css exports, available since webpack 5.90.0
266269
// type: boolean
267270
namedExports: true,
@@ -281,9 +284,65 @@ module.exports = {
281284
};
282285
```
283286

284-
### module.parser.css.namedExports
287+
### module.parser.css
288+
289+
Configure options for the CSS parser.
290+
291+
```js
292+
module.exports = {
293+
module: {
294+
parser: {
295+
css: {
296+
// ...
297+
namedExports: true,
298+
},
299+
},
300+
},
301+
};
302+
```
303+
304+
#### module.parser.css.import
305+
306+
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.
307+
308+
- Type: `boolean`
309+
- Available: 5.97.0+
310+
- Example:
311+
312+
```js
313+
module.exports = {
314+
module: {
315+
parser: {
316+
css: {
317+
import: true,
318+
},
319+
},
320+
},
321+
};
322+
```
323+
324+
```css
325+
/* reset-styles.css */
326+
body {
327+
margin: 0;
328+
padding: 0;
329+
}
330+
```
331+
332+
```css
333+
/* styles.css */
334+
@import './reset-styles.css';
335+
336+
body {
337+
background-color: red;
338+
}
339+
```
340+
341+
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.
342+
343+
#### module.parser.css.namedExports
285344

286-
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.
345+
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.
287346

288347
- Type: `boolean`
289348
- Available: 5.90.0+

0 commit comments

Comments
 (0)