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
feat: allow to disable css modules and disable their by default (#842)
BREAKING CHANGE: by default css modules are disabled (now `modules: false` disable all css modules features), you can return old behaviour change this on `modules: 'global'`
The query parameter `modules` enables the **CSS Modules** spec.
132
+
The `modules`option enables/disables the **CSS Modules** spec and setup basic behaviour.
133
133
134
-
This enables local scoped CSS by default. (You can switch it off with `:global(...)` or `:global` for selectors and/or rules.).
134
+
|Name|Type|Description|
135
+
|:--:|:--:|:----------|
136
+
|**`true`**|`{Boolean}`|Enables local scoped CSS by default (use **local** mode by default)|
137
+
|**`false`**|`{Boolean}`|Disable the **CSS Modules** spec, all **CSS Modules** features (like `@value`, `:local`, `:global` and `composes`) will not work|
138
+
|**`'local'`**|`{String}`|Enables local scoped CSS by default (same as `true` value)|
139
+
|**`'global'`**|`{String}`|Enables global scoped CSS by default|
140
+
141
+
Using `false` value increase performance because we avoid parsing **CSS Modules** features, it will be useful for developers who use vanilla css or use other technologies.
142
+
143
+
You can read about **modes** below
135
144
136
-
#### `Scope`
145
+
##### `Scope`
146
+
147
+
Using `local` value requires you to specify `:global` classes.
148
+
Using `global` value requires you to specify `:local` classes.
137
149
138
-
By default CSS exports all classnames into a global selector scope. Styles can be locally scoped to avoid globally scoping styles.
150
+
You can find more information [here](https://github.com/css-modules/css-modules).
151
+
152
+
Styles can be locally scoped to avoid globally scoping styles.
139
153
140
154
The syntax `:local(.className)` can be used to declare `className` in the local scope. The local identifiers are exported by the module.
141
155
142
-
With `:local` (without brackets) local mode can be switched on for this selector. `:global(.className)` can be used to declare an explicit global selector. With `:global` (without brackets) global mode can be switched on for this selector.
156
+
With `:local` (without brackets) local mode can be switched on for this selector.
157
+
The `:global(.className)` nocation can be used to declare an explicit global selector.
158
+
With `:global` (without brackets) global mode can be switched on for this selector.
143
159
144
160
The loader replaces local selectors with unique identifiers. The chosen unique identifiers are exported by the module.
145
161
@@ -177,7 +193,7 @@ file.png => ./file.png
177
193
178
194
You can use `:local(#someId)`, but this is not recommended. Use classes instead of ids.
179
195
180
-
#### `Composing`
196
+
#####`Composing`
181
197
182
198
When declaring a local classname you can compose a local class from another local classname.
183
199
@@ -213,7 +229,7 @@ exports.locals = {
213
229
}
214
230
```
215
231
216
-
#### `Importing`
232
+
#####`Importing`
217
233
218
234
To import a local classname from another module.
219
235
@@ -282,7 +298,7 @@ You can also specify the absolute path to your custom `getLocalIdent` function t
282
298
283
299
To include source maps set the `sourceMap` option.
284
300
285
-
I.e. the extract-text-webpack-plugin can handle them.
301
+
I.e. the `mini-css-extract-plugin` can handle them.
286
302
287
303
They are not enabled by default because they expose a runtime overhead and increase in bundle size (JS source maps do not). In addition to that relative paths are buggy and you need to use an absolute public path which includes the server URL.
exports.push([module.id, \\"@import url(test-other.css) (min-width: 100px);\\\\n\\\\n@value def from './values.css';\\\\n@value other from './values.css';\\\\n@value other from './values.css';\\\\n@value something from './something.css';\\\\n@value foo: blue;\\\\n@value bar: block;\\\\n\\\\n.ghi {\\\\ncolor: def;\\\\n}\\\\n\\\\n.class {\\\\ncolor: foo;\\\\n}\\\\n\\\\n.other {\\\\ndisplay: bar;\\\\n}\\\\n\\\\n.other-other {\\\\nwidth: something;\\\\n}\\\\n\\\\n.green {\\\\ncolor: other;\\\\n}\\\\n\\\\n.foo {\\\\nprop: def;\\\\nduplicate: other;\\\\n}\\\\n\\", \\"\\"]);
55
+
56
+
// exports
57
+
"
58
+
`;
59
+
60
+
exports[`import option false and modules \`false\`: warnings 1`] =`Array []`;
61
+
62
+
exports[`import option false and modules \`global\`: errors 1`] =`Array []`;
63
+
64
+
exports[`import option false and modules \`global\`: module (evaluated) 1`] =`
6
65
Array [
7
66
Array [
8
67
2,
@@ -50,7 +109,7 @@ Array [
50
109
]
51
110
`;
52
111
53
-
exports[`import option false and modules false: module 1`] =`
112
+
exports[`import option false and modules \`global\`: module 1`] =`
0 commit comments