Skip to content

Commit faca47b

Browse files
docs: update
1 parent 18b4fec commit faca47b

File tree

3 files changed

+45
-28
lines changed

3 files changed

+45
-28
lines changed

README.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,10 @@ module.exports = {
122122
Type: `Boolean|Object`
123123
Default: `true`
124124

125-
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.
125+
Allow to enable/disables handling the CSS functions `url` and `image-set`.
126+
If set to `false`, `css-loader` will not parse any paths specified in `url` or `image-set`.
127+
A function can also be passed to control this behavior dynamically based on the path to the asset.
128+
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.
126129

127130
Examples resolutions:
128131

@@ -203,7 +206,7 @@ module.exports = {
203206
Type: `Boolean|Object`
204207
Default: `true`
205208

206-
Enables/Disables `@import` at-rules handling.
209+
Allows to enables/disables `@import` at-rules handling.
207210
Control `@import` resolving. Absolute urls in `@import` will be moved in runtime code.
208211

209212
Examples resolutions:
@@ -335,9 +338,15 @@ This may change in the future when the module system (i. e. webpack) supports lo
335338
### `modules`
336339

337340
Type: `Boolean|String|Object`
338-
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)
341+
Default: `undefined`
342+
343+
Allows to enable/disable CSS Modules or ICSS and setup configuration:
339344

340-
Enables/Disables CSS Modules and their configuration.
345+
- `undefined` - enable CSS modules for all files matching `/\.module\.\w+$/i.test(filename)` and `/\.icss\.\w+$/i.test(filename)` regexp.
346+
- `true` - enable CSS modules for all files.
347+
- `false` - disables CSS Modules for all files.
348+
- `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)
349+
- `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)
341350

342351
The `modules` option enables/disables the **[CSS Modules](https://github.com/css-modules/css-modules)** specification and setup basic behaviour.
343352

@@ -598,9 +607,17 @@ module.exports = {
598607
##### `auto`
599608

600609
Type: `Boolean|RegExp|Function`
601-
Default: `'true'`
610+
Default: `undefined`
611+
612+
Allows auto enable CSS modules/ICSS based on filename when `modules` option is object.
613+
614+
Possible values:
602615

603-
Allows auto enable CSS modules based on filename.
616+
- `undefined` - enable CSS modules for all files.
617+
- `true` - enable CSS modules for all files matching `/\.module\.\w+$/i.test(filename)` and `/\.icss\.\w+$/i.test(filename)` regexp.
618+
- `false` - disables CSS Modules.
619+
- `RegExp` - enable CSS modules for all files matching `/RegExp/i.test(filename)` regexp.
620+
- `function` - enable CSS Modules for files based on the filename satisfying your filter function check.
604621

605622
###### `Boolean`
606623

src/options.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"additionalProperties": false,
44
"properties": {
55
"url": {
6-
"description": "Enables/Disables 'url'/'image-set' functions handling (https://github.com/webpack-contrib/css-loader#url).",
6+
"description": "Allow to enable/disables handling the CSS functions `url` and `image-set` (https://github.com/webpack-contrib/css-loader#url).",
77
"anyOf": [
88
{
99
"type": "boolean"
@@ -20,7 +20,7 @@
2020
]
2121
},
2222
"import": {
23-
"description": "Enables/Disables '@import' at-rules handling (https://github.com/webpack-contrib/css-loader#import).",
23+
"description": "Allows to enables/disables `@import` at-rules handling (https://github.com/webpack-contrib/css-loader#import).",
2424
"anyOf": [
2525
{
2626
"type": "boolean"
@@ -51,7 +51,7 @@
5151
]
5252
},
5353
"modules": {
54-
"description": "Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules).",
54+
"description": "Allows to enable/disable CSS Modules or ICSS and setup configuration (https://github.com/webpack-contrib/css-loader#modules).",
5555
"anyOf": [
5656
{
5757
"type": "boolean"
@@ -160,7 +160,7 @@
160160
]
161161
},
162162
"sourceMap": {
163-
"description": "Enables/Disables generation of source maps (https://github.com/webpack-contrib/css-loader#sourcemap).",
163+
"description": "Allows to enable/disable source maps (https://github.com/webpack-contrib/css-loader#sourcemap).",
164164
"type": "boolean"
165165
},
166166
"esModule": {

test/__snapshots__/validate-options.test.js.snap

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ exports[`validate options should throw an error on the "import" option with "()
1010
"Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema.
1111
- options.import should be one of these:
1212
boolean | object { filter?, loaders? }
13-
-> Enables/Disables '@import' at-rules handling (https://github.com/webpack-contrib/css-loader#import).
13+
-> Allows to enables/disables \`@import\` at-rules handling (https://github.com/webpack-contrib/css-loader#import).
1414
Details:
1515
* options.import should be a boolean.
1616
* options.import should be an object:
@@ -21,7 +21,7 @@ exports[`validate options should throw an error on the "import" option with "[]"
2121
"Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema.
2222
- options.import should be one of these:
2323
boolean | object { filter?, loaders? }
24-
-> Enables/Disables '@import' at-rules handling (https://github.com/webpack-contrib/css-loader#import).
24+
-> Allows to enables/disables \`@import\` at-rules handling (https://github.com/webpack-contrib/css-loader#import).
2525
Details:
2626
* options.import should be a boolean.
2727
* options.import should be an object:
@@ -37,7 +37,7 @@ exports[`validate options should throw an error on the "import" option with "{"l
3737
"Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema.
3838
- options.import should be one of these:
3939
boolean | object { filter?, loaders? }
40-
-> Enables/Disables '@import' at-rules handling (https://github.com/webpack-contrib/css-loader#import).
40+
-> Allows to enables/disables \`@import\` at-rules handling (https://github.com/webpack-contrib/css-loader#import).
4141
Details:
4242
* options.import.loaders should be one of these:
4343
boolean | string | integer
@@ -58,7 +58,7 @@ exports[`validate options should throw an error on the "import" option with "tru
5858
"Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema.
5959
- options.import should be one of these:
6060
boolean | object { filter?, loaders? }
61-
-> Enables/Disables '@import' at-rules handling (https://github.com/webpack-contrib/css-loader#import).
61+
-> Allows to enables/disables \`@import\` at-rules handling (https://github.com/webpack-contrib/css-loader#import).
6262
Details:
6363
* options.import should be a boolean.
6464
* options.import should be an object:
@@ -69,7 +69,7 @@ exports[`validate options should throw an error on the "modules" option with "{"
6969
"Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema.
7070
- options.modules should be one of these:
7171
boolean | \\"local\\" | \\"global\\" | \\"pure\\" | \\"icss\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashSalt?, localIdentHashFunction?, localIdentHashDigest?, localIdentHashDigestLength?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? }
72-
-> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules).
72+
-> Allows to enable/disable CSS Modules or ICSS and setup configuration (https://github.com/webpack-contrib/css-loader#modules).
7373
Details:
7474
* options.modules.auto should be one of these:
7575
RegExp | function | boolean
@@ -127,7 +127,7 @@ exports[`validate options should throw an error on the "modules" option with "{"
127127
"Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema.
128128
- options.modules should be one of these:
129129
boolean | \\"local\\" | \\"global\\" | \\"pure\\" | \\"icss\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashSalt?, localIdentHashFunction?, localIdentHashDigest?, localIdentHashDigestLength?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? }
130-
-> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules).
130+
-> Allows to enable/disable CSS Modules or ICSS and setup configuration (https://github.com/webpack-contrib/css-loader#modules).
131131
Details:
132132
* options.modules.localIdentRegExp should be one of these:
133133
non-empty string | RegExp
@@ -141,7 +141,7 @@ exports[`validate options should throw an error on the "modules" option with "{"
141141
"Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema.
142142
- options.modules should be one of these:
143143
boolean | \\"local\\" | \\"global\\" | \\"pure\\" | \\"icss\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashSalt?, localIdentHashFunction?, localIdentHashDigest?, localIdentHashDigestLength?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? }
144-
-> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules).
144+
-> Allows to enable/disable CSS Modules or ICSS and setup configuration (https://github.com/webpack-contrib/css-loader#modules).
145145
Details:
146146
* options.modules.mode should be one of these:
147147
\\"local\\" | \\"global\\" | \\"pure\\" | \\"icss\\" | function
@@ -156,7 +156,7 @@ exports[`validate options should throw an error on the "modules" option with "{"
156156
"Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema.
157157
- options.modules should be one of these:
158158
boolean | \\"local\\" | \\"global\\" | \\"pure\\" | \\"icss\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashSalt?, localIdentHashFunction?, localIdentHashDigest?, localIdentHashDigestLength?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? }
159-
-> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules).
159+
-> Allows to enable/disable CSS Modules or ICSS and setup configuration (https://github.com/webpack-contrib/css-loader#modules).
160160
Details:
161161
* options.modules.mode should be one of these:
162162
\\"local\\" | \\"global\\" | \\"pure\\" | \\"icss\\" | function
@@ -171,7 +171,7 @@ exports[`validate options should throw an error on the "modules" option with "{"
171171
"Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema.
172172
- options.modules should be one of these:
173173
boolean | \\"local\\" | \\"global\\" | \\"pure\\" | \\"icss\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashSalt?, localIdentHashFunction?, localIdentHashDigest?, localIdentHashDigestLength?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? }
174-
-> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules).
174+
-> Allows to enable/disable CSS Modules or ICSS and setup configuration (https://github.com/webpack-contrib/css-loader#modules).
175175
Details:
176176
* options.modules.mode should be one of these:
177177
\\"local\\" | \\"global\\" | \\"pure\\" | \\"icss\\" | function
@@ -186,7 +186,7 @@ exports[`validate options should throw an error on the "modules" option with "{"
186186
"Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema.
187187
- options.modules should be one of these:
188188
boolean | \\"local\\" | \\"global\\" | \\"pure\\" | \\"icss\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashSalt?, localIdentHashFunction?, localIdentHashDigest?, localIdentHashDigestLength?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? }
189-
-> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules).
189+
-> Allows to enable/disable CSS Modules or ICSS and setup configuration (https://github.com/webpack-contrib/css-loader#modules).
190190
Details:
191191
* options.modules.mode should be one of these:
192192
\\"local\\" | \\"global\\" | \\"pure\\" | \\"icss\\" | function
@@ -207,7 +207,7 @@ exports[`validate options should throw an error on the "modules" option with "gl
207207
"Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema.
208208
- options.modules should be one of these:
209209
boolean | \\"local\\" | \\"global\\" | \\"pure\\" | \\"icss\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashSalt?, localIdentHashFunction?, localIdentHashDigest?, localIdentHashDigestLength?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? }
210-
-> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules).
210+
-> Allows to enable/disable CSS Modules or ICSS and setup configuration (https://github.com/webpack-contrib/css-loader#modules).
211211
Details:
212212
* options.modules should be a boolean.
213213
* options.modules should be one of these:
@@ -220,7 +220,7 @@ exports[`validate options should throw an error on the "modules" option with "lo
220220
"Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema.
221221
- options.modules should be one of these:
222222
boolean | \\"local\\" | \\"global\\" | \\"pure\\" | \\"icss\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashSalt?, localIdentHashFunction?, localIdentHashDigest?, localIdentHashDigestLength?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? }
223-
-> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules).
223+
-> Allows to enable/disable CSS Modules or ICSS and setup configuration (https://github.com/webpack-contrib/css-loader#modules).
224224
Details:
225225
* options.modules should be a boolean.
226226
* options.modules should be one of these:
@@ -233,7 +233,7 @@ exports[`validate options should throw an error on the "modules" option with "pu
233233
"Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema.
234234
- options.modules should be one of these:
235235
boolean | \\"local\\" | \\"global\\" | \\"pure\\" | \\"icss\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashSalt?, localIdentHashFunction?, localIdentHashDigest?, localIdentHashDigestLength?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? }
236-
-> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules).
236+
-> Allows to enable/disable CSS Modules or ICSS and setup configuration (https://github.com/webpack-contrib/css-loader#modules).
237237
Details:
238238
* options.modules should be a boolean.
239239
* options.modules should be one of these:
@@ -246,7 +246,7 @@ exports[`validate options should throw an error on the "modules" option with "tr
246246
"Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema.
247247
- options.modules should be one of these:
248248
boolean | \\"local\\" | \\"global\\" | \\"pure\\" | \\"icss\\" | object { auto?, mode?, localIdentName?, localIdentContext?, localIdentHashSalt?, localIdentHashFunction?, localIdentHashDigest?, localIdentHashDigestLength?, localIdentRegExp?, getLocalIdent?, namedExport?, exportGlobals?, exportLocalsConvention?, exportOnlyLocals? }
249-
-> Enables/Disables CSS Modules and their configuration (https://github.com/webpack-contrib/css-loader#modules).
249+
-> Allows to enable/disable CSS Modules or ICSS and setup configuration (https://github.com/webpack-contrib/css-loader#modules).
250250
Details:
251251
* options.modules should be a boolean.
252252
* options.modules should be one of these:
@@ -258,7 +258,7 @@ exports[`validate options should throw an error on the "modules" option with "tr
258258
exports[`validate options should throw an error on the "sourceMap" option with "true" value 1`] = `
259259
"Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema.
260260
- options.sourceMap should be a boolean.
261-
-> Enables/Disables generation of source maps (https://github.com/webpack-contrib/css-loader#sourcemap)."
261+
-> Allows to enable/disable source maps (https://github.com/webpack-contrib/css-loader#sourcemap)."
262262
`;
263263

264264
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 "() =>
313313
"Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema.
314314
- options.url should be one of these:
315315
boolean | object { filter? }
316-
-> Enables/Disables 'url'/'image-set' functions handling (https://github.com/webpack-contrib/css-loader#url).
316+
-> Allow to enable/disables handling the CSS functions \`url\` and \`image-set\` (https://github.com/webpack-contrib/css-loader#url).
317317
Details:
318318
* options.url should be a boolean.
319319
* options.url should be an object:
@@ -324,7 +324,7 @@ exports[`validate options should throw an error on the "url" option with "[]" va
324324
"Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema.
325325
- options.url should be one of these:
326326
boolean | object { filter? }
327-
-> Enables/Disables 'url'/'image-set' functions handling (https://github.com/webpack-contrib/css-loader#url).
327+
-> Allow to enable/disables handling the CSS functions \`url\` and \`image-set\` (https://github.com/webpack-contrib/css-loader#url).
328328
Details:
329329
* options.url should be a boolean.
330330
* options.url should be an object:
@@ -346,7 +346,7 @@ exports[`validate options should throw an error on the "url" option with "true"
346346
"Invalid options object. CSS Loader has been initialized using an options object that does not match the API schema.
347347
- options.url should be one of these:
348348
boolean | object { filter? }
349-
-> Enables/Disables 'url'/'image-set' functions handling (https://github.com/webpack-contrib/css-loader#url).
349+
-> Allow to enable/disables handling the CSS functions \`url\` and \`image-set\` (https://github.com/webpack-contrib/css-loader#url).
350350
Details:
351351
* options.url should be a boolean.
352352
* options.url should be an object:

0 commit comments

Comments
 (0)