From 0b09431c627d7f8dfeaf95f87cf4e9aa51adb7b9 Mon Sep 17 00:00:00 2001 From: cap-Bernardito Date: Wed, 14 Jul 2021 22:14:40 +0300 Subject: [PATCH 1/2] docs: update --- README.md | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 163ee861..49ae6111 100644 --- a/README.md +++ b/README.md @@ -335,9 +335,15 @@ This may change in the future when the module system (i. e. webpack) supports lo ### `modules` Type: `Boolean|String|Object` -Default: based on filename, `true` for all files matching `/\.module\.\w+$/i.test(filename)` regular expression, more information you can read [here](https://github.com/webpack-contrib/css-loader#auto) +Default: `undefined` + +Enables/Disables CSS Modules and their configuration: -Enables/Disables CSS Modules and their configuration. +- `undefined` - processed all files matching `/\.module\.\w+$/i.test(filename)` and `/\.icss\.\w+$/i.test(filename)` regular expression +- `true` - processed all files +- `false` - disables CSS Modules +- `string` - processed all files, more information you can read [here](https://github.com/webpack-contrib/css-loader#mode) +- `object` - processed all files, when `modules.auto` option is not specified, more information you can read [here](https://github.com/webpack-contrib/css-loader#auto) The `modules` option enables/disables the **[CSS Modules](https://github.com/css-modules/css-modules)** specification and setup basic behaviour. @@ -598,9 +604,17 @@ module.exports = { ##### `auto` Type: `Boolean|RegExp|Function` -Default: `'true'` +Default: `undefined` + +Allows auto enable CSS modules based on filename when `modules` option is object. + +Possible values: -Allows auto enable CSS modules based on filename. +- `undefined` - processed all files +- `true` - processed all files matching `/\.module\.\w+$/i.test(filename)` and `/\.icss\.\w+$/i.test(filename)` regular expression +- `false` - disables CSS Modules +- `RegExp` - processed all files matching `/RegExp/i.test(filename)` regular expression +- `Function` - enable CSS Modules for files based on the filename satisfying your filter function check. ###### `Boolean` From e03057c2f58224f0ea9a17fc7147da9d95c35357 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Wed, 14 Jul 2021 23:46:32 +0300 Subject: [PATCH 2/2] docs: update + test --- README.md | 31 ++++++++-------- src/options.json | 8 ++--- .../validate-options.test.js.snap | 36 +++++++++---------- 3 files changed, 39 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 49ae6111..1fc3f37d 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,10 @@ module.exports = { Type: `Boolean|Object` Default: `true` -Enables/Disables handling the CSS functions `url` and `image-set`. If set to `false`, `css-loader` will not parse any paths specified in `url` or `image-set`. A function can also be passed to control this behavior dynamically based on the path to the asset. Starting with version [4.0.0](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#400-2020-07-25), absolute paths are parsed based on the server root. +Allow to enable/disables handling the CSS functions `url` and `image-set`. +If set to `false`, `css-loader` will not parse any paths specified in `url` or `image-set`. +A function can also be passed to control this behavior dynamically based on the path to the asset. +Starting with version [4.0.0](https://github.com/webpack-contrib/css-loader/blob/master/CHANGELOG.md#400-2020-07-25), absolute paths are parsed based on the server root. Examples resolutions: @@ -203,7 +206,7 @@ module.exports = { Type: `Boolean|Object` Default: `true` -Enables/Disables `@import` at-rules handling. +Allows to enables/disables `@import` at-rules handling. Control `@import` resolving. Absolute urls in `@import` will be moved in runtime code. Examples resolutions: @@ -337,13 +340,13 @@ This may change in the future when the module system (i. e. webpack) supports lo Type: `Boolean|String|Object` Default: `undefined` -Enables/Disables CSS Modules and their configuration: +Allows to enable/disable CSS Modules or ICSS and setup configuration: -- `undefined` - processed all files matching `/\.module\.\w+$/i.test(filename)` and `/\.icss\.\w+$/i.test(filename)` regular expression -- `true` - processed all files -- `false` - disables CSS Modules -- `string` - processed all files, more information you can read [here](https://github.com/webpack-contrib/css-loader#mode) -- `object` - processed all files, when `modules.auto` option is not specified, more information you can read [here](https://github.com/webpack-contrib/css-loader#auto) +- `undefined` - enable CSS modules for all files matching `/\.module\.\w+$/i.test(filename)` and `/\.icss\.\w+$/i.test(filename)` regexp. +- `true` - enable CSS modules for all files. +- `false` - disables CSS Modules for all files. +- `string` - disables CSS Modules for all files and set the `mode` option, more information you can read [here](https://github.com/webpack-contrib/css-loader#mode) +- `object` - enable CSS modules for all files, if `modules.auto` option is not specified, otherwise the `modules.auto` option will determine whether if it is CSS modules or not, more information you can read [here](https://github.com/webpack-contrib/css-loader#auto) The `modules` option enables/disables the **[CSS Modules](https://github.com/css-modules/css-modules)** specification and setup basic behaviour. @@ -606,15 +609,15 @@ module.exports = { Type: `Boolean|RegExp|Function` Default: `undefined` -Allows auto enable CSS modules based on filename when `modules` option is object. +Allows auto enable CSS modules/ICSS based on filename when `modules` option is object. Possible values: -- `undefined` - processed all files -- `true` - processed all files matching `/\.module\.\w+$/i.test(filename)` and `/\.icss\.\w+$/i.test(filename)` regular expression -- `false` - disables CSS Modules -- `RegExp` - processed all files matching `/RegExp/i.test(filename)` regular expression -- `Function` - enable CSS Modules for files based on the filename satisfying your filter function check. +- `undefined` - enable CSS modules for all files. +- `true` - enable CSS modules for all files matching `/\.module\.\w+$/i.test(filename)` and `/\.icss\.\w+$/i.test(filename)` regexp. +- `false` - disables CSS Modules. +- `RegExp` - enable CSS modules for all files matching `/RegExp/i.test(filename)` regexp. +- `function` - enable CSS Modules for files based on the filename satisfying your filter function check. ###### `Boolean` diff --git a/src/options.json b/src/options.json index b4f1ca77..d063737d 100644 --- a/src/options.json +++ b/src/options.json @@ -3,7 +3,7 @@ "additionalProperties": false, "properties": { "url": { - "description": "Enables/Disables 'url'/'image-set' functions handling (https://github.com/webpack-contrib/css-loader#url).", + "description": "Allow to enable/disables handling the CSS functions `url` and `image-set` (https://github.com/webpack-contrib/css-loader#url).", "anyOf": [ { "type": "boolean" @@ -20,7 +20,7 @@ ] }, "import": { - "description": "Enables/Disables '@import' at-rules handling (https://github.com/webpack-contrib/css-loader#import).", + "description": "Allows to enables/disables `@import` at-rules handling (https://github.com/webpack-contrib/css-loader#import).", "anyOf": [ { "type": "boolean" @@ -51,7 +51,7 @@ ] }, "modules": { - "description": "Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules).", + "description": "Allows to enable/disable CSS Modules or ICSS and setup configuration (https://github.com/webpack-contrib/css-loader#modules).", "anyOf": [ { "type": "boolean" @@ -160,7 +160,7 @@ ] }, "sourceMap": { - "description": "Enables/Disables generation of source maps (https://github.com/webpack-contrib/css-loader#sourcemap).", + "description": "Allows to enable/disable source maps (https://github.com/webpack-contrib/css-loader#sourcemap).", "type": "boolean" }, "esModule": { diff --git a/test/__snapshots__/validate-options.test.js.snap b/test/__snapshots__/validate-options.test.js.snap index 0b39d2e4..7f6017f9 100644 --- a/test/__snapshots__/validate-options.test.js.snap +++ b/test/__snapshots__/validate-options.test.js.snap @@ -10,7 +10,7 @@ exports[`validate options should throw an error on the "import" option with "() "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.import should be one of these: boolean | object { filter?, loaders? } - -> Enables/Disables '@import' at-rules handling (https://github.com/webpack-contrib/css-loader#import). + -> Allows to enables/disables \`@import\` at-rules handling (https://github.com/webpack-contrib/css-loader#import). Details: * options.import should be a boolean. * options.import should be an object: @@ -21,7 +21,7 @@ exports[`validate options should throw an error on the "import" option with "[]" "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.import should be one of these: boolean | object { filter?, loaders? } - -> Enables/Disables '@import' at-rules handling (https://github.com/webpack-contrib/css-loader#import). + -> Allows to enables/disables \`@import\` at-rules handling (https://github.com/webpack-contrib/css-loader#import). Details: * options.import should be a boolean. * options.import should be an object: @@ -37,7 +37,7 @@ exports[`validate options should throw an error on the "import" option with "{"l "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.import should be one of these: boolean | object { filter?, loaders? } - -> Enables/Disables '@import' at-rules handling (https://github.com/webpack-contrib/css-loader#import). + -> Allows to enables/disables \`@import\` at-rules handling (https://github.com/webpack-contrib/css-loader#import). Details: * options.import.loaders should be one of these: boolean | string | integer @@ -58,7 +58,7 @@ exports[`validate options should throw an error on the "import" option with "tru "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.import should be one of these: boolean | object { filter?, loaders? } - -> Enables/Disables '@import' at-rules handling (https://github.com/webpack-contrib/css-loader#import). + -> Allows to enables/disables \`@import\` at-rules handling (https://github.com/webpack-contrib/css-loader#import). Details: * options.import should be a boolean. * options.import should be an object: @@ -69,7 +69,7 @@ exports[`validate options should throw an error on the "modules" option with "{" "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.modules should be one of these: boolean | \\"local\\" | \\"global\\" | \\"pure\\" | \\"icss\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashSalt?, localIdentHashFunction?, localIdentHashDigest?, localIdentHashDigestLength?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } - -> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules). + -> Allows to enable/disable CSS Modules or ICSS and setup configuration (https://github.com/webpack-contrib/css-loader#modules). Details: * options.modules.auto should be one of these: RegExp | function | boolean @@ -127,7 +127,7 @@ exports[`validate options should throw an error on the "modules" option with "{" "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.modules should be one of these: boolean | \\"local\\" | \\"global\\" | \\"pure\\" | \\"icss\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashSalt?, localIdentHashFunction?, localIdentHashDigest?, localIdentHashDigestLength?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } - -> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules). + -> Allows to enable/disable CSS Modules or ICSS and setup configuration (https://github.com/webpack-contrib/css-loader#modules). Details: * options.modules.localIdentRegExp should be one of these: non-empty string | RegExp @@ -141,7 +141,7 @@ exports[`validate options should throw an error on the "modules" option with "{" "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.modules should be one of these: boolean | \\"local\\" | \\"global\\" | \\"pure\\" | \\"icss\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashSalt?, localIdentHashFunction?, localIdentHashDigest?, localIdentHashDigestLength?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } - -> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules). + -> Allows to enable/disable CSS Modules or ICSS and setup configuration (https://github.com/webpack-contrib/css-loader#modules). Details: * options.modules.mode should be one of these: \\"local\\" | \\"global\\" | \\"pure\\" | \\"icss\\" | function @@ -156,7 +156,7 @@ exports[`validate options should throw an error on the "modules" option with "{" "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.modules should be one of these: boolean | \\"local\\" | \\"global\\" | \\"pure\\" | \\"icss\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashSalt?, localIdentHashFunction?, localIdentHashDigest?, localIdentHashDigestLength?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } - -> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules). + -> Allows to enable/disable CSS Modules or ICSS and setup configuration (https://github.com/webpack-contrib/css-loader#modules). Details: * options.modules.mode should be one of these: \\"local\\" | \\"global\\" | \\"pure\\" | \\"icss\\" | function @@ -171,7 +171,7 @@ exports[`validate options should throw an error on the "modules" option with "{" "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.modules should be one of these: boolean | \\"local\\" | \\"global\\" | \\"pure\\" | \\"icss\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashSalt?, localIdentHashFunction?, localIdentHashDigest?, localIdentHashDigestLength?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } - -> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules). + -> Allows to enable/disable CSS Modules or ICSS and setup configuration (https://github.com/webpack-contrib/css-loader#modules). Details: * options.modules.mode should be one of these: \\"local\\" | \\"global\\" | \\"pure\\" | \\"icss\\" | function @@ -186,7 +186,7 @@ exports[`validate options should throw an error on the "modules" option with "{" "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.modules should be one of these: boolean | \\"local\\" | \\"global\\" | \\"pure\\" | \\"icss\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashSalt?, localIdentHashFunction?, localIdentHashDigest?, localIdentHashDigestLength?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } - -> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules). + -> Allows to enable/disable CSS Modules or ICSS and setup configuration (https://github.com/webpack-contrib/css-loader#modules). Details: * options.modules.mode should be one of these: \\"local\\" | \\"global\\" | \\"pure\\" | \\"icss\\" | function @@ -207,7 +207,7 @@ exports[`validate options should throw an error on the "modules" option with "gl "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.modules should be one of these: boolean | \\"local\\" | \\"global\\" | \\"pure\\" | \\"icss\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashSalt?, localIdentHashFunction?, localIdentHashDigest?, localIdentHashDigestLength?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } - -> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules). + -> Allows to enable/disable CSS Modules or ICSS and setup configuration (https://github.com/webpack-contrib/css-loader#modules). Details: * options.modules should be a boolean. * options.modules should be one of these: @@ -220,7 +220,7 @@ exports[`validate options should throw an error on the "modules" option with "lo "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.modules should be one of these: boolean | \\"local\\" | \\"global\\" | \\"pure\\" | \\"icss\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashSalt?, localIdentHashFunction?, localIdentHashDigest?, localIdentHashDigestLength?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } - -> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules). + -> Allows to enable/disable CSS Modules or ICSS and setup configuration (https://github.com/webpack-contrib/css-loader#modules). Details: * options.modules should be a boolean. * options.modules should be one of these: @@ -233,7 +233,7 @@ exports[`validate options should throw an error on the "modules" option with "pu "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.modules should be one of these: boolean | \\"local\\" | \\"global\\" | \\"pure\\" | \\"icss\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashSalt?, localIdentHashFunction?, localIdentHashDigest?, localIdentHashDigestLength?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } - -> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules). + -> Allows to enable/disable CSS Modules or ICSS and setup configuration (https://github.com/webpack-contrib/css-loader#modules). Details: * options.modules should be a boolean. * options.modules should be one of these: @@ -246,7 +246,7 @@ exports[`validate options should throw an error on the "modules" option with "tr "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.modules should be one of these: boolean | \\"local\\" | \\"global\\" | \\"pure\\" | \\"icss\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashSalt?, localIdentHashFunction?, localIdentHashDigest?, localIdentHashDigestLength?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? } - -> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules). + -> Allows to enable/disable CSS Modules or ICSS and setup configuration (https://github.com/webpack-contrib/css-loader#modules). Details: * options.modules should be a boolean. * options.modules should be one of these: @@ -258,7 +258,7 @@ exports[`validate options should throw an error on the "modules" option with "tr exports[`validate options should throw an error on the "sourceMap" option with "true" value 1`] = ` "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.sourceMap should be a boolean. - -> Enables/Disables generation of source maps (https://github.com/webpack-contrib/css-loader#sourcemap)." + -> Allows to enable/disable source maps (https://github.com/webpack-contrib/css-loader#sourcemap)." `; exports[`validate options should throw an error on the "unknown" option with "/test/" value 1`] = ` @@ -313,7 +313,7 @@ exports[`validate options should throw an error on the "url" option with "() => "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.url should be one of these: boolean | object { filter? } - -> Enables/Disables 'url'/'image-set' functions handling (https://github.com/webpack-contrib/css-loader#url). + -> Allow to enable/disables handling the CSS functions \`url\` and \`image-set\` (https://github.com/webpack-contrib/css-loader#url). Details: * options.url should be a boolean. * options.url should be an object: @@ -324,7 +324,7 @@ exports[`validate options should throw an error on the "url" option with "[]" va "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.url should be one of these: boolean | object { filter? } - -> Enables/Disables 'url'/'image-set' functions handling (https://github.com/webpack-contrib/css-loader#url). + -> Allow to enable/disables handling the CSS functions \`url\` and \`image-set\` (https://github.com/webpack-contrib/css-loader#url). Details: * options.url should be a boolean. * options.url should be an object: @@ -346,7 +346,7 @@ exports[`validate options should throw an error on the "url" option with "true" "Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema. - options.url should be one of these: boolean | object { filter? } - -> Enables/Disables 'url'/'image-set' functions handling (https://github.com/webpack-contrib/css-loader#url). + -> Allow to enable/disables handling the CSS functions \`url\` and \`image-set\` (https://github.com/webpack-contrib/css-loader#url). Details: * options.url should be a boolean. * options.url should be an object: