Skip to content

Commit 22879b6

Browse files
committed
docs(guides): clarify native CSS migration from css-loader/mini-css-extract-plugin
Add a concrete diff showing how to remove MiniCssExtractPlugin.loader and the plugin instance when using experiments.css.
1 parent e46c3cf commit 22879b6

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

src/content/guides/native-css.mdx

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ export default {
187187
generator: {
188188
"css/module": {
189189
exportsConvention: "camel-case-only",
190-
localIdentName: "[uniqueName]-[id]-[local]",
190+
localIdentName: "[local]-[hash:base64:6]",
191191
},
192192
},
193193
},
@@ -199,13 +199,36 @@ Notes:
199199
- `import` and `url` are native parser switches for CSS handling.
200200
- `namedExports` controls CSS Modules exports behavior.
201201
- `exportsConvention` and `localIdentName` provide class export/name shaping.
202+
- `localIdentName` supports hash placeholders (for example `[hash:base64:6]`); you can tune hashing globally with [`output.hashFunction`](/configuration/output/#outputhashfunction), [`output.hashDigest`](/configuration/output/#outputhashdigest), [`output.hashDigestLength`](/configuration/output/#outputhashdigestlength), and [`output.hashSalt`](/configuration/output/#outputhashsalt).
202203
- `css-loader` filter-style options are not available as direct equivalents; use webpack mechanisms such as `IgnorePlugin` when needed.
203204

204205
### 4) Replace `mini-css-extract-plugin`
205206

206207
When `experiments.css` is enabled, webpack provides native CSS extraction and content hash handling for CSS output files.
207208

208-
That means you can remove:
209+
**webpack.config.js**
210+
211+
```diff
212+
-import MiniCssExtractPlugin from "mini-css-extract-plugin";
213+
-
214+
export default {
215+
+ experiments: {
216+
+ css: true,
217+
+ },
218+
module: {
219+
rules: [
220+
{
221+
test: /\.css$/i,
222+
- use: [MiniCssExtractPlugin.loader, "css-loader"],
223+
+ use: ["css-loader"],
224+
},
225+
],
226+
},
227+
- plugins: [new MiniCssExtractPlugin()],
228+
};
229+
```
230+
231+
You can remove:
209232

210233
- `MiniCssExtractPlugin.loader` from `module.rules`,
211234
- the `new MiniCssExtractPlugin()` plugin instance.

0 commit comments

Comments
 (0)