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
docs(module): exportsConvention function form now accepts string[] (#8240)
Webpack 5.107 lets the generator.exportsConvention function for CSS
modules return either a string or a string[]. Returning an array
exports the local class under every name in the array, matching
css-loader's behavior. Updates the type comments in the module.generator
example and adds a dedicated subsection with a worked example.
Refs: webpack/webpack#20914
// available since webpack 5.90.4; the function form may return string[] since 5.107.0
184
184
exportsConvention:"camel-case-only",
185
185
186
186
// Customize the format of the local class names generated for css modules.
@@ -205,6 +205,35 @@ export default {
205
205
};
206
206
```
207
207
208
+
### Multiple aliases via `exportsConvention`
209
+
210
+
<Badgetext="5.107.0+" />
211
+
212
+
When `exportsConvention` is a function, it may return either a `string` or a `string[]`. Returning an array exports the local class under every name in the array, matching `css-loader`'s behavior. This is useful when you want to expose the same class under several aliases without writing two rules.
213
+
214
+
**webpack.config.js**
215
+
216
+
```js
217
+
exportdefault {
218
+
experiments: { css:true },
219
+
module: {
220
+
generator: {
221
+
"css/module": {
222
+
// expose each class under both its original name and an uppercase alias
0 commit comments