Skip to content

Commit

Permalink
docs(module): add module.parser.css.import option (#7490)
Browse files Browse the repository at this point in the history
  • Loading branch information
snitin315 authored Dec 9, 2024
1 parent bf76271 commit 86ae32b
Showing 1 changed file with 61 additions and 2 deletions.
63 changes: 61 additions & 2 deletions src/content/configuration/module.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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> 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

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+
Expand Down

0 comments on commit 86ae32b

Please sign in to comment.