You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/guides/native-css.mdx
+8-3Lines changed: 8 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,7 +51,10 @@ Webpack will process the CSS and include it in the build output.
51
51
52
52
## CSS Modules
53
53
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.
55
58
56
59
**src/button.module.css**
57
60
@@ -209,7 +212,7 @@ That means you can remove:
209
212
210
213
### 5) Replace `style-loader` with `exportType: "style"`
211
214
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"`:
213
216
214
217
**webpack.config.js**
215
218
@@ -222,7 +225,7 @@ export default {
222
225
rules: [
223
226
{
224
227
test:/\.css$/i,
225
-
type:"css/module",
228
+
type:"css/auto",
226
229
parser: {
227
230
exportType:"style",
228
231
},
@@ -234,6 +237,8 @@ export default {
234
237
235
238
This mode injects a `<style>` element from the webpack runtime and covers the typical `style-loader` use case.
236
239
240
+
If you cannot rename files to the CSS Modules naming convention, you can use `type: "css/module"` directly for the relevant rule.
0 commit comments