Skip to content

Commit 3fd426d

Browse files
bjohansebasclaude
andcommitted
docs(blog): point the CSS migration at the new codemod
webpack/codemods ships @webpack/css-plugins-to-native-css, which does the mini-css-extract-plugin and style-loader/css-loader migration the post describes by hand. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 97b866f commit 3fd426d

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/content/blog/2026-08-26-webpack-5-110.mdx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,17 @@ Since 5.109 that support defaults to `'auto'`: it turns itself on unless a loade
161161

162162
### Migrating
163163

164-
In most projects, migrating is deleting configuration:
164+
You do not have to do it by hand. There is now a [webpack codemods](https://github.com/webpack/codemods) repository, and its first codemod migrates exactly this:
165+
166+
```sh
167+
npx codemod run @webpack/css-plugins-to-native-css
168+
```
169+
170+
It removes the rules that only wire up `style-loader`, `css-loader` and `MiniCssExtractPlugin.loader`, drops the plugin and its import, and moves the options that have a native counterpart: the plugin's `filename` and `chunkFilename` become [`output.cssFilename`](/configuration/output/#outputcssfilename) and [`output.cssChunkFilename`](/configuration/output/#outputcsschunkfilename), `css-loader`'s `modules` sub-options become the rule's `generator` and `parser` options, and a preprocessor left in the chain keeps working with `type: "css/auto"` added to its rule.
171+
172+
It understands the shapes real configs come in, including the `isDev ? "style-loader" : MiniCssExtractPlugin.loader` ternary that ejected Create React App configs use, function-form configs and `webpack-merge` fragments. Anything without a native equivalent is dropped with a comment naming what went, so you can review the change rather than discover it later.
173+
174+
Underneath, in most projects migrating is deleting configuration:
165175

166176
```diff
167177
export default {

0 commit comments

Comments
 (0)