Skip to content

refactor: improve schema options #1123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 34 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ module.exports = {
Type: `Boolean|RegExp|Function`
Default: `'true'`

Allows auto enable css modules based on filename.
Allows auto enable CSS modules based on filename.

###### `Boolean`

Expand Down Expand Up @@ -694,39 +694,12 @@ module.exports = {
};
```

##### `exportGlobals`

Type: `Boolean`
Default: `false`

Allow `css-loader` to export names from global class or id, so you can use that as local name.

**webpack.config.js**

```js
module.exports = {
module: {
rules: [
{
test: /\.css$/i,
loader: 'css-loader',
options: {
modules: {
exportGlobals: true,
},
},
},
],
},
};
```

##### `localIdentName`

Type: `String`
Default: `'[hash:base64]'`

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

Recommendations:
Expand Down Expand Up @@ -763,7 +736,7 @@ module.exports = {
Type: `String`
Default: `compiler.context`

Allow to redefine basic loader context for local ident name.
Allows to redefine basic loader context for local ident name.

**webpack.config.js**

Expand All @@ -790,7 +763,7 @@ module.exports = {
Type: `String`
Default: `undefined`

Allow to add custom hash to generate more unique classes.
Allows to add custom hash to generate more unique classes.

**webpack.config.js**

Expand Down Expand Up @@ -842,7 +815,7 @@ module.exports = {
Type: `Function`
Default: `undefined`

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

**webpack.config.js**
Expand Down Expand Up @@ -872,8 +845,8 @@ module.exports = {
Type: `Boolean`
Default: `false`

Enable/disable ES modules named export for css classes.
Names of exported classes are converted to camelCase.
Enables/disables ES modules named export for locals.
Names of locals are converted to camelCase.

> i It is not allowed to use JavaScript reserved words in css class names

Expand Down Expand Up @@ -919,6 +892,33 @@ module.exports = {
};
```

##### `exportGlobals`

Type: `Boolean`
Default: `false`

Allow `css-loader` to export names from global class or id, so you can use that as local name.

**webpack.config.js**

```js
module.exports = {
module: {
rules: [
{
test: /\.css$/i,
loader: 'css-loader',
options: {
modules: {
exportGlobals: true,
},
},
},
],
},
};
```

##### `exportlocalsConvention`

Type: `String`
Expand Down
16 changes: 12 additions & 4 deletions src/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"additionalProperties": false,
"properties": {
"auto": {
"description": "Allows auto enable CSS modules based on filename (https://github.com/webpack-contrib/css-loader#auto).",
"anyOf": [
{
"instanceof": "RegExp"
Expand All @@ -50,6 +51,7 @@
]
},
"mode": {
"description": "Setup `mode` option (https://github.com/webpack-contrib/css-loader#mode).",
"anyOf": [
{
"enum": ["local", "global", "pure"]
Expand All @@ -59,22 +61,23 @@
}
]
},
"exportGlobals": {
"type": "boolean"
},
"localIdentName": {
"description": "Allows to configure the generated local ident name (https://github.com/webpack-contrib/css-loader#localidentname).",
"type": "string",
"minLength": 1
},
"localIdentContext": {
"description": "Allows to redefine basic loader context for local ident name (https://github.com/webpack-contrib/css-loader#localidentcontext).",
"type": "string",
"minLength": 1
},
"localIdentHashPrefix": {
"description": "Allows to add custom hash to generate more unique classes (https://github.com/webpack-contrib/css-loader#localidenthashprefix).",
"type": "string",
"minLength": 1
},
"localIdentRegExp": {
"description": "Allows to specify custom RegExp for local ident name (https://github.com/webpack-contrib/css-loader#localidentregexp).",
"anyOf": [
{
"type": "string",
Expand All @@ -86,10 +89,15 @@
]
},
"getLocalIdent": {
"description": "Allows to specify a function to generate the classname (https://github.com/webpack-contrib/css-loader#getlocalident).",
"instanceof": "Function"
},
"namedExport": {
"description": "Use the named export ES modules.",
"description": "Enables/disables ES modules named export for locals (https://github.com/webpack-contrib/css-loader#namedexport).",
"type": "boolean"
},
"exportGlobals": {
"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).",
"type": "boolean"
},
"exportLocalsConvention": {
Expand Down
Loading