Skip to content

Commit c153fe6

Browse files
refactor: improve schema options (webpack-contrib#1123)
1 parent 58b4b98 commit c153fe6

File tree

3 files changed

+77
-58
lines changed

3 files changed

+77
-58
lines changed

README.md

+34-34
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ module.exports = {
549549
Type: `Boolean|RegExp|Function`
550550
Default: `'true'`
551551

552-
Allows auto enable css modules based on filename.
552+
Allows auto enable CSS modules based on filename.
553553

554554
###### `Boolean`
555555

@@ -694,39 +694,12 @@ module.exports = {
694694
};
695695
```
696696

697-
##### `exportGlobals`
698-
699-
Type: `Boolean`
700-
Default: `false`
701-
702-
Allow `css-loader` to export names from global class or id, so you can use that as local name.
703-
704-
**webpack.config.js**
705-
706-
```js
707-
module.exports = {
708-
module: {
709-
rules: [
710-
{
711-
test: /\.css$/i,
712-
loader: 'css-loader',
713-
options: {
714-
modules: {
715-
exportGlobals: true,
716-
},
717-
},
718-
},
719-
],
720-
},
721-
};
722-
```
723-
724697
##### `localIdentName`
725698

726699
Type: `String`
727700
Default: `'[hash:base64]'`
728701

729-
You can configure the generated ident with the `localIdentName` option.
702+
Allows to configure the generated local ident name.
730703
See [loader-utils's documentation](https://github.com/webpack/loader-utils#interpolatename) for more information on options.
731704

732705
Recommendations:
@@ -763,7 +736,7 @@ module.exports = {
763736
Type: `String`
764737
Default: `compiler.context`
765738

766-
Allow to redefine basic loader context for local ident name.
739+
Allows to redefine basic loader context for local ident name.
767740

768741
**webpack.config.js**
769742

@@ -790,7 +763,7 @@ module.exports = {
790763
Type: `String`
791764
Default: `undefined`
792765

793-
Allow to add custom hash to generate more unique classes.
766+
Allows to add custom hash to generate more unique classes.
794767

795768
**webpack.config.js**
796769

@@ -842,7 +815,7 @@ module.exports = {
842815
Type: `Function`
843816
Default: `undefined`
844817

845-
You can also specify the absolute path to your custom `getLocalIdent` function to generate classname based on a different schema.
818+
Allows to specify a function to generate the classname.
846819
By default we use built-in function to generate a classname.
847820

848821
**webpack.config.js**
@@ -872,8 +845,8 @@ module.exports = {
872845
Type: `Boolean`
873846
Default: `false`
874847

875-
Enable/disable ES modules named export for css classes.
876-
Names of exported classes are converted to camelCase.
848+
Enables/disables ES modules named export for locals.
849+
Names of locals are converted to camelCase.
877850

878851
> i It is not allowed to use JavaScript reserved words in css class names
879852
@@ -919,6 +892,33 @@ module.exports = {
919892
};
920893
```
921894

895+
##### `exportGlobals`
896+
897+
Type: `Boolean`
898+
Default: `false`
899+
900+
Allow `css-loader` to export names from global class or id, so you can use that as local name.
901+
902+
**webpack.config.js**
903+
904+
```js
905+
module.exports = {
906+
module: {
907+
rules: [
908+
{
909+
test: /\.css$/i,
910+
loader: 'css-loader',
911+
options: {
912+
modules: {
913+
exportGlobals: true,
914+
},
915+
},
916+
},
917+
],
918+
},
919+
};
920+
```
921+
922922
##### `exportlocalsConvention`
923923

924924
Type: `String`

src/options.json

+12-4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"additionalProperties": false,
3838
"properties": {
3939
"auto": {
40+
"description": "Allows auto enable CSS modules based on filename (https://github.com/webpack-contrib/css-loader#auto).",
4041
"anyOf": [
4142
{
4243
"instanceof": "RegExp"
@@ -50,6 +51,7 @@
5051
]
5152
},
5253
"mode": {
54+
"description": "Setup `mode` option (https://github.com/webpack-contrib/css-loader#mode).",
5355
"anyOf": [
5456
{
5557
"enum": ["local", "global", "pure"]
@@ -59,22 +61,23 @@
5961
}
6062
]
6163
},
62-
"exportGlobals": {
63-
"type": "boolean"
64-
},
6564
"localIdentName": {
65+
"description": "Allows to configure the generated local ident name (https://github.com/webpack-contrib/css-loader#localidentname).",
6666
"type": "string",
6767
"minLength": 1
6868
},
6969
"localIdentContext": {
70+
"description": "Allows to redefine basic loader context for local ident name (https://github.com/webpack-contrib/css-loader#localidentcontext).",
7071
"type": "string",
7172
"minLength": 1
7273
},
7374
"localIdentHashPrefix": {
75+
"description": "Allows to add custom hash to generate more unique classes (https://github.com/webpack-contrib/css-loader#localidenthashprefix).",
7476
"type": "string",
7577
"minLength": 1
7678
},
7779
"localIdentRegExp": {
80+
"description": "Allows to specify custom RegExp for local ident name (https://github.com/webpack-contrib/css-loader#localidentregexp).",
7881
"anyOf": [
7982
{
8083
"type": "string",
@@ -86,10 +89,15 @@
8689
]
8790
},
8891
"getLocalIdent": {
92+
"description": "Allows to specify a function to generate the classname (https://github.com/webpack-contrib/css-loader#getlocalident).",
8993
"instanceof": "Function"
9094
},
9195
"namedExport": {
92-
"description": "Use the named export ES modules.",
96+
"description": "Enables/disables ES modules named export for locals (https://github.com/webpack-contrib/css-loader#namedexport).",
97+
"type": "boolean"
98+
},
99+
"exportGlobals": {
100+
"description": "Allows to export names from global class or id, so you can use that as local name (https://github.com/webpack-contrib/css-loader#exportglobals).",
93101
"type": "boolean"
94102
},
95103
"exportLocalsConvention": {

0 commit comments

Comments
 (0)