Skip to content

Commit e46c3cf

Browse files
committed
docs(guides): recommend css/auto with module naming for native css migration
1 parent 2213920 commit e46c3cf

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/content/guides/native-css.mdx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ Webpack will process the CSS and include it in the build output.
5151

5252
## CSS Modules
5353

54-
Native CSS support also includes CSS Modules. Use the `.module.css` extension:
54+
Native CSS support also includes CSS Modules. The recommended approach is:
55+
56+
- keep `type: "css/auto"` for mixed CSS handling,
57+
- use `.module.css` (or `.modules.css`) naming for CSS Modules files.
5558

5659
**src/button.module.css**
5760

@@ -209,7 +212,7 @@ That means you can remove:
209212

210213
### 5) Replace `style-loader` with `exportType: "style"`
211214

212-
If you used `style-loader` for runtime style injection, use CSS module parser `exportType: "style"`:
215+
If you used `style-loader` for runtime style injection, keep `css/auto` and use module naming (`.module.css` or `.modules.css`), then set `exportType: "style"`:
213216

214217
**webpack.config.js**
215218

@@ -222,7 +225,7 @@ export default {
222225
rules: [
223226
{
224227
test: /\.css$/i,
225-
type: "css/module",
228+
type: "css/auto",
226229
parser: {
227230
exportType: "style",
228231
},
@@ -234,6 +237,8 @@ export default {
234237

235238
This mode injects a `<style>` element from the webpack runtime and covers the typical `style-loader` use case.
236239

240+
If you cannot rename files to the CSS Modules naming convention, you can use `type: "css/module"` directly for the relevant rule.
241+
237242
### 6) Keep imports unchanged
238243

239244
Your JS imports can stay the same:

0 commit comments

Comments
 (0)