css-loader 7.1.1 → 7.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -16,11 +16,11 @@
16
16
 
17
17
  # css-loader
18
18
 
19
- The `css-loader` interprets `@import` and `url()` like `import/require()` and will resolve them.
19
+ The `css-loader` interprets `@import` and `url()` like `import/require()` and resolves them.
20
20
 
21
21
  ## Getting Started
22
22
 
23
- > **Warning**
23
+ > [!WARNING]
24
24
  >
25
25
  > To use the latest version of css-loader, webpack@5 is required
26
26
 
@@ -42,7 +42,7 @@ or
42
42
  pnpm add -D css-loader
43
43
  ```
44
44
 
45
- Then add the plugin to your `webpack` config. For example:
45
+ Then, add the loader to your `webpack` configuration. For example:
46
46
 
47
47
  **file.js**
48
48
 
@@ -65,9 +65,9 @@ module.exports = {
65
65
  };
66
66
  ```
67
67
 
68
- And run `webpack` via your preferred method.
68
+ Finally, run `webpack` using the method you normally use (e.g., via CLI or an npm script).
69
69
 
70
- If, for one reason or another, you need to extract CSS as a file (i.e. do not store CSS in a JS module) you might want to check out the [recommend example](https://github.com/webpack-contrib/css-loader#recommend).
70
+ If you need to extract CSS into a separate file (i.e. do not store CSS in a JS module), consider using the [recommend example](https://github.com/webpack/css-loader#recommend).
71
71
 
72
72
  ## Options
73
73
 
@@ -93,10 +93,12 @@ type url =
93
93
 
94
94
  Default: `true`
95
95
 
96
- Allow to enable/disables handling the CSS functions `url` and `image-set`.
97
- If set to `false`, `css-loader` will not parse any paths specified in `url` or `image-set`.
98
- A function can also be passed to control this behavior dynamically based on the path to the asset.
99
- 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.
96
+ Enables or disables handling the CSS functions `url` and `image-set`.
97
+
98
+ - If set to `false`, `css-loader` will not parse any paths specified in `url` or `image-set`.
99
+ - You can also pass a function to control this behavior dynamically based on the asset path.
100
+
101
+ As of version [4.0.0](https://github.com/webpack/css-loader/main/CHANGELOG.md#400-2020-07-25), absolute paths are resolved based on the server root.
100
102
 
101
103
  Examples resolutions:
102
104
 
@@ -109,7 +111,7 @@ url('http://dontwritehorriblecode.com/2112.png') => require('http://dontwritehor
109
111
  image-set(url('image2x.png') 1x, url('image1x.png') 2x) => require('./image1x.png') and require('./image2x.png')
110
112
  ```
111
113
 
112
- To import assets from a `node_modules` path (include `resolve.modules`) and for `alias`, prefix it with a `~`:
114
+ To import assets from a `node_modules` path (including `resolve.modules`) or an `alias`, prefix it with a `~`:
113
115
 
114
116
  ```js
115
117
  url(~module/image.png) => require('module/image.png')
@@ -141,7 +143,9 @@ module.exports = {
141
143
 
142
144
  #### `object`
143
145
 
144
- Allow to filter `url()`. All filtered `url()` will not be resolved (left in the code as they were written).
146
+ Allows filtering of `url()` values.
147
+
148
+ Any filtered `url()` will not be resolved (left in the code as they were written).
145
149
 
146
150
  **webpack.config.js**
147
151
 
@@ -163,7 +167,7 @@ module.exports = {
163
167
  }
164
168
 
165
169
  // Don't handle images under root-relative /external_images/
166
- if (/^\/external_images\//.test(path)) {
170
+ if (/^\/external_images\//.test(url)) {
167
171
  return false;
168
172
  }
169
173
 
@@ -199,8 +203,11 @@ type importFn =
199
203
 
200
204
  Default: `true`
201
205
 
202
- Allows to enables/disables `@import` at-rules handling.
203
- Control `@import` resolving. Absolute urls in `@import` will be moved in runtime code.
206
+ Allows you to enable or disable handling of `@import` at-rules.
207
+
208
+ Controls how `@import` statements are resolved.
209
+
210
+ Absolute URLs in `@import` will be moved in runtime code.
204
211
 
205
212
  Examples resolutions:
206
213
 
@@ -214,7 +221,7 @@ Examples resolutions:
214
221
  @import url('http://dontwritehorriblecode.com/style.css') => @import url('http://dontwritehorriblecode.com/style.css') in runtime
215
222
  ```
216
223
 
217
- To import styles from a `node_modules` path (include `resolve.modules`) and for `alias`, prefix it with a `~`:
224
+ To import styles from a `node_modules` path (include `resolve.modules`) or an `alias`, prefix it with a `~`:
218
225
 
219
226
  ```
220
227
  @import url(~module/style.css) => require('module/style.css')
@@ -256,7 +263,9 @@ type filter = (url: string, media: string, resourcePath: string) => boolean;
256
263
 
257
264
  Default: `undefined`
258
265
 
259
- Allow to filter `@import`. All filtered `@import` will not be resolved (left in the code as they were written).
266
+ Allows filtering of `@import`.
267
+
268
+ Any filtered `@import` will not be resolved (left in the code as they were written).
260
269
 
261
270
  **webpack.config.js**
262
271
 
@@ -343,17 +352,17 @@ type modules =
343
352
 
344
353
  Default: `undefined`
345
354
 
346
- Allows to enable/disable CSS Modules or ICSS and setup configuration:
355
+ Allows you to enable or disable CSS Modules or ICSS and configure them:
347
356
 
348
- - `undefined` - enable CSS modules for all files matching `/\.module\.\w+$/i.test(filename)` and `/\.icss\.\w+$/i.test(filename)` regexp.
349
- - `true` - enable CSS modules for all files.
350
- - `false` - disables CSS Modules for all files.
351
- - `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)
352
- - `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)
357
+ - `undefined`: Enables CSS modules for all files matching `/\.module\.\w+$/i.test(filename)` or `/\.icss\.\w+$/i.test(filename)` regexp.
358
+ - `true`: Enables CSS modules for all files.
359
+ - `false`: Disables CSS Modules for all files.
360
+ - `string`: Disables CSS Modules for all files and set the `mode` option (see [mode](https://github.com/webpack/css-loader#mode) for details).
361
+ - `object`: Enables CSS modules for all files unless the `modules.auto` option is provided. otherwise the `modules.auto` option will determine whether if it is CSS Modules or not (see [auto](https://github.com/webpack/css-loader#auto) for more details).
353
362
 
354
- The `modules` option enables/disables the **[CSS Modules](https://github.com/css-modules/css-modules)** specification and setup basic behaviour.
363
+ The `modules` option enables/disables the **[CSS Modules](https://github.com/css-modules/css-modules)** specification and configures its behavior.
355
364
 
356
- Using `false` value increase performance because we avoid parsing **CSS Modules** features, it will be useful for developers who use vanilla css or use other technologies.
365
+ Setting `modules: false` can improve performance because we avoid parsing **CSS Modules** features, this is useful for developers using use vanilla CSS or other technologies.
357
366
 
358
367
  **webpack.config.js**
359
368
 
@@ -377,21 +386,21 @@ module.exports = {
377
386
 
378
387
  ##### `Scope`
379
388
 
380
- Using `local` value requires you to specify `:global` classes.
381
- Using `global` value requires you to specify `:local` classes.
382
- Using `pure` value requires selectors must contain at least one local class or id.
389
+ - Using `local` value requires you to specify `:global` classes.
390
+ - Using `global` value requires you to specify `:local` classes.
391
+ - Using `pure` value requires selectors must contain at least one local class or ID.
383
392
 
384
- You can find more information [here](https://github.com/css-modules/css-modules).
393
+ You can find more information on scoping module [here](https://github.com/css-modules/css-modules).
385
394
 
386
- Styles can be locally scoped to avoid globally scoping styles.
395
+ With CSS Modules, styles are scoped locally, preventing conflicts with global styles.
387
396
 
388
- The syntax `:local(.className)` can be used to declare `className` in the local scope. The local identifiers are exported by the module.
397
+ Use `:local(.className)` to declare a `className` in the local scope. The local identifiers are exported by the module.
389
398
 
390
- With `:local` (without brackets) local mode can be switched on for this selector.
391
- The `:global(.className)` notation can be used to declare an explicit global selector.
392
- With `:global` (without brackets) global mode can be switched on for this selector.
399
+ - With `:local` (without parentheses) local mode can be switched `on` for this selector.
400
+ - The `:global(.className)` notation can be used to declare an explicit global selector.
401
+ - With `:global` (without parentheses) global mode can be switched `on` for this selector.
393
402
 
394
- The loader replaces local selectors with unique identifiers. The chosen unique identifiers are exported by the module.
403
+ The loader replaces local selectors with unique, scoped identifiers. The chosen unique identifiers are exported by the module.
395
404
 
396
405
  ```css
397
406
  :local(.className) {
@@ -408,6 +417,8 @@ The loader replaces local selectors with unique identifiers. The chosen unique i
408
417
  }
409
418
  ```
410
419
 
420
+ Output (example):
421
+
411
422
  ```css
412
423
  ._23_aKvs-b8bW2Vg3fwHozO {
413
424
  background: red;
@@ -423,7 +434,7 @@ The loader replaces local selectors with unique identifiers. The chosen unique i
423
434
  }
424
435
  ```
425
436
 
426
- > **Note**
437
+ > [!NOTE]
427
438
  >
428
439
  > Identifiers are exported
429
440
 
@@ -434,13 +445,13 @@ exports.locals = {
434
445
  };
435
446
  ```
436
447
 
437
- CamelCase is recommended for local selectors. They are easier to use within the imported JS module.
448
+ CamelCase naming is recommended for local selectors, as it simplifies usage in imported JS modules.
438
449
 
439
- You can use `:local(#someId)`, but this is not recommended. Use classes instead of ids.
450
+ Although you can use `:local(#someId)`, but this is not recommended. Prefer classes instead of IDs for modular styling.
440
451
 
441
452
  ##### `Composing`
442
453
 
443
- When declaring a local classname you can compose a local class from another local classname.
454
+ When declaring a local class name, you can compose it from one or more other local class names.
444
455
 
445
456
  ```css
446
457
  :local(.className) {
@@ -454,7 +465,7 @@ When declaring a local classname you can compose a local class from another loca
454
465
  }
455
466
  ```
456
467
 
457
- This doesn't result in any change to the CSS itself but exports multiple classnames.
468
+ This does not alter the final CSS output, but the generated `subClass` will include both class names in its export.
458
469
 
459
470
  ```js
460
471
  exports.locals = {
@@ -476,11 +487,11 @@ exports.locals = {
476
487
 
477
488
  ##### `Importing`
478
489
 
479
- To import a local classname from another module.
490
+ To import a local class names from another module.
480
491
 
481
- > **Note**
492
+ > [!NOTE]
482
493
  >
483
- > We strongly recommend that you specify the extension when importing a file, since it is possible to import a file with any extension and it is not known in advance which file to use.
494
+ > It is highly recommended to include file extensions when importing a file, since it is possible to import a file with any extension and it is not known in advance which file to use.
484
495
 
485
496
  ```css
486
497
  :local(.continueButton) {
@@ -523,7 +534,11 @@ or
523
534
 
524
535
  You can use `@value` to specific values to be reused throughout a document.
525
536
 
526
- We recommend use prefix `v-` for values, `s-` for selectors and `m-` for media at-rules.
537
+ We recommend following a naming convention:
538
+
539
+ - `v-` prefix for values
540
+ - `s-` prefix for selectors
541
+ - `m-` prefix for media at-rules.
527
542
 
528
543
  ```css
529
544
  @value v-primary: #BF4040;
@@ -593,7 +608,7 @@ module.exports = {
593
608
 
594
609
  #### `object`
595
610
 
596
- Enable **CSS Modules** features and setup options for them.
611
+ Enable **CSS Modules** features and configure its behavior through `options`.
597
612
 
598
613
  **webpack.config.js**
599
614
 
@@ -641,22 +656,22 @@ type auto =
641
656
 
642
657
  Default: `undefined`
643
658
 
644
- Allows auto enable CSS modules/ICSS based on the filename, query or fragment when `modules` option is object.
659
+ Allows auto enable CSS modules or ICSS based on the file name, query or fragment when `modules` option is an object.
645
660
 
646
661
  Possible values:
647
662
 
648
- - `undefined` - enable CSS modules for all files.
649
- - `true` - enable CSS modules for all files matching `/\.module\.\w+$/i.test(filename)` and `/\.icss\.\w+$/i.test(filename)` regexp.
650
- - `false` - disables CSS Modules.
651
- - `RegExp` - enable CSS modules for all files matching `/RegExp/i.test(filename)` regexp.
652
- - `function` - enable CSS Modules for files based on the filename satisfying your filter function check.
663
+ - `undefined`: Enables CSS modules for all files.
664
+ - `true`: Enables CSS modules for files matching `/\.module\.\w+$/i.test(filename)` and `/\.icss\.\w+$/i.test(filename)` regexp.
665
+ - `false`: Disables CSS Modules for all files.
666
+ - `RegExp`: Enables CSS modules for all files matching `/RegExp/i.test(filename)` regexp.
667
+ - `function`: Enables CSS Modules for files based on the file name satisfying your filter function check.
653
668
 
654
669
  ###### `boolean`
655
670
 
656
671
  Possible values:
657
672
 
658
- - `true` - enables CSS modules or interoperable CSS format, sets the [`modules.mode`](#mode) option to `local` value for all files which satisfy `/\.module(s)?\.\w+$/i.test(filename)` condition or sets the [`modules.mode`](#mode) option to `icss` value for all files which satisfy `/\.icss\.\w+$/i.test(filename)` condition
659
- - `false` - disables CSS modules or interoperable CSS format based on filename
673
+ - `true`: Enables CSS modules or Interoperable CSS (ICSS) format, sets the [`modules.mode`](#mode) option to `local` value for all files which satisfy `/\.module(s)?\.\w+$/i.test(filename)` condition or sets the [`modules.mode`](#mode) option to `icss` value for all files which satisfy `/\.icss\.\w+$/i.test(filename)` condition.
674
+ - `false`: Disables CSS modules or ICSS format based on filename for all files.
660
675
 
661
676
  **webpack.config.js**
662
677
 
@@ -680,7 +695,7 @@ module.exports = {
680
695
 
681
696
  ###### `RegExp`
682
697
 
683
- Enable CSS modules for files based on the filename satisfying your regex check.
698
+ Enables CSS modules for files based on the filename satisfying your regex check.
684
699
 
685
700
  **webpack.config.js**
686
701
 
@@ -704,7 +719,7 @@ module.exports = {
704
719
 
705
720
  ###### `function`
706
721
 
707
- Enable CSS modules for files based on the filename, query or fragment satisfying your filter function check.
722
+ Enables CSS Modules for files based on the filename, query or fragment satisfying your filter function check.
708
723
 
709
724
  **webpack.config.js**
710
725
 
@@ -751,8 +766,8 @@ Setup `mode` option. You can omit the value when you want `local` mode.
751
766
 
752
767
  Controls the level of compilation applied to the input styles.
753
768
 
754
- The `local`, `global`, and `pure` handles `class` and `id` scoping and `@value` values.
755
- The `icss` will only compile the low level `Interoperable CSS` format for declaring `:import` and `:export` dependencies between CSS and other languages.
769
+ - The `local`, `global`, and `pure` handles `class` and `id` scoping and `@value` values.
770
+ - The `icss` will only compile the low level `Interoperable CSS (ICSS)` format for declaring `:import` and `:export` dependencies between CSS and other languages.
756
771
 
757
772
  ICSS underpins CSS Module support, and provides a low level syntax for other tools to implement CSS-module variations of their own.
758
773
 
@@ -782,8 +797,7 @@ module.exports = {
782
797
 
783
798
  ###### `function`
784
799
 
785
- Allows set different values for the `mode` option based on the filename, query or fragment.
786
-
800
+ Allows setting different values for the `mode` option based on the filename, query or fragment.
787
801
  Possible return values - `local`, `global`, `pure` and `icss`.
788
802
 
789
803
  **webpack.config.js**
@@ -850,12 +864,12 @@ Supported template strings:
850
864
 
851
865
  Recommendations:
852
866
 
853
- - use `'[path][name]__[local]'` for development
854
- - use `'[hash:base64]'` for production
867
+ - Use `'[path][name]__[local]'` for development
868
+ - Use `'[hash:base64]'` for production
855
869
 
856
870
  The `[local]` placeholder contains original class.
857
871
 
858
- **Note:** all reserved (`<>:"/\|?*`) and control filesystem characters (excluding characters in the `[local]` placeholder) will be converted to `-`.
872
+ **Note:** all reserved characters (`<>:"/\|?*`) and control filesystem characters (excluding characters in the `[local]` placeholder) will be converted to `-`.
859
873
 
860
874
  **webpack.config.js**
861
875
 
@@ -887,7 +901,7 @@ type localIdentContex = string;
887
901
 
888
902
  Default: `compiler.context`
889
903
 
890
- Allows to redefine basic loader context for local ident name.
904
+ Allows redefining the basic loader context for local ident name.
891
905
 
892
906
  **webpack.config.js**
893
907
 
@@ -920,6 +934,7 @@ type localIdentHashSalt = string;
920
934
  Default: `undefined`
921
935
 
922
936
  Allows to add custom hash to generate more unique classes.
937
+
923
938
  For more information see [output.hashSalt](https://webpack.js.org/configuration/output/#outputhashsalt).
924
939
 
925
940
  **webpack.config.js**
@@ -953,6 +968,7 @@ type localIdentHashFunction = string;
953
968
  Default: `md4`
954
969
 
955
970
  Allows to specify hash function to generate classes .
971
+
956
972
  For more information see [output.hashFunction](https://webpack.js.org/configuration/output/#outputhashfunction).
957
973
 
958
974
  **webpack.config.js**
@@ -986,6 +1002,7 @@ type localIdentHashDigest = string;
986
1002
  Default: `hex`
987
1003
 
988
1004
  Allows to specify hash digest to generate classes.
1005
+
989
1006
  For more information see [output.hashDigest](https://webpack.js.org/configuration/output/#outputhashdigest).
990
1007
 
991
1008
  **webpack.config.js**
@@ -1019,7 +1036,8 @@ type localIdentHashDigestLength = number;
1019
1036
  Default: `20`
1020
1037
 
1021
1038
  Allows to specify hash digest length to generate classes.
1022
- For more information see [output.hashDigestLength](https://webpack.js.org/configuration/output/#outputhashdigestlength).
1039
+
1040
+ For more information, see [output.hashDigestLength](https://webpack.js.org/configuration/output/#outputhashdigestlength).
1023
1041
 
1024
1042
  **webpack.config.js**
1025
1043
 
@@ -1116,9 +1134,10 @@ type getLocalIdent = (
1116
1134
  Default: `undefined`
1117
1135
 
1118
1136
  Allows to specify a function to generate the classname.
1137
+
1119
1138
  By default we use built-in function to generate a classname.
1120
- If the custom function returns `null` or `undefined`, we fallback to the
1121
- built-in function to generate the classname.
1139
+
1140
+ If your custom function returns `null` or `undefined`, the built-in generator is used as a `fallback`.
1122
1141
 
1123
1142
  **webpack.config.js**
1124
1143
 
@@ -1150,13 +1169,13 @@ Type:
1150
1169
  type namedExport = boolean;
1151
1170
  ```
1152
1171
 
1153
- Default: Depends on the value of the `esModule` option. If the value of the `esModule` options is `true`, this value will also be `true`, otherwise it will be `false`.
1172
+ Default: Depends on the value of the `esModule` option. If the value of the `esModule` options is `true`, `namedExport` defaults to `true` ; otherwise, it defaults to `false`.
1154
1173
 
1155
- Enables/disables ES modules named export for locals.
1174
+ Enables or disables ES modules named export for locals.
1156
1175
 
1157
- > **Warning**
1176
+ > [!WARNING]
1158
1177
  >
1159
- > Because it is not allowed to use the `default` class in CSS when the `namedExport` is `true` (since ECMA modules have a reserved keyword `default` for default export), it will be automatically renamed to the `_default` class.
1178
+ > The `default` class name cannot be used directly when `namedExport` is `true` because `default` is a reserved keyword in ECMAScript modules. It is automatically renamed to `_default`.
1160
1179
 
1161
1180
  **styles.css**
1162
1181
 
@@ -1187,7 +1206,7 @@ console.log(styles.fooBaz, styles.bar);
1187
1206
  console.log(styles["_default"]);
1188
1207
  ```
1189
1208
 
1190
- You can enable a ES module named export using:
1209
+ You can enable ES module named export using:
1191
1210
 
1192
1211
  **webpack.config.js**
1193
1212
 
@@ -1211,7 +1230,8 @@ module.exports = {
1211
1230
  ```
1212
1231
 
1213
1232
  To set a custom name for namedExport, can use [`exportLocalsConvention`](#exportLocalsConvention) option as a function.
1214
- Example below in the [`examples`](#examples) section.
1233
+
1234
+ See below in the [`examples`](#examples) section.
1215
1235
 
1216
1236
  ##### `exportGlobals`
1217
1237
 
@@ -1223,7 +1243,7 @@ type exportsGLobals = boolean;
1223
1243
 
1224
1244
  Default: `false`
1225
1245
 
1226
- Allow `css-loader` to export names from global class or id, so you can use that as local name.
1246
+ Allow `css-loader` to export names from global class or ID, so you can use that as local name.
1227
1247
 
1228
1248
  **webpack.config.js**
1229
1249
 
@@ -1259,13 +1279,15 @@ type exportLocalsConvention =
1259
1279
  | ((name: string) => string);
1260
1280
  ```
1261
1281
 
1262
- Default: Depends on the value of the `modules.namedExport` option, if `true` - `as-is`, otherwise `camel-case-only`.
1282
+ Default: Depends on the value of the `modules.namedExport` option:
1263
1283
 
1264
- > **Warning**
1284
+ - If `true` - `as-is`
1285
+ - Otherwise `camel-case-only` (class names converted to camelCase, original name removed).
1286
+
1287
+ > [!WARNING]
1265
1288
  >
1266
- > Names of locals are converted to camelcase when the named export is `false`, i.e. the `exportLocalsConvention` option has
1267
- > `camelCaseOnly` value by default. You can set this back to any other valid option but selectors
1268
- > which are not valid JavaScript identifiers may run into problems which do not implement the entire modules specification.
1289
+ > Names of locals are converted to camelCase when the named export is `false`, i.e. the `exportLocalsConvention` option has`camelCaseOnly` value by default.
1290
+ > You can set this back to any other valid option but selectors which are not valid JavaScript identifiers may run into problems which do not implement the entire modules specification.
1269
1291
 
1270
1292
  Style of exported class names.
1271
1293
 
@@ -1273,13 +1295,13 @@ Style of exported class names.
1273
1295
 
1274
1296
  By default, the exported JSON keys mirror the class names (i.e `as-is` value).
1275
1297
 
1276
- | Name | Type | Description |
1277
- | :---------------------: | :------: | :----------------------------------------------------------------------------------------------- |
1278
- | **`'as-is'`** | `string` | Class names will be exported as is. |
1279
- | **`'camel-case'`** | `string` | Class names will be camelized, the original class name will not to be removed from the locals |
1280
- | **`'camel-case-only'`** | `string` | Class names will be camelized, the original class name will be removed from the locals |
1281
- | **`'dashes'`** | `string` | Only dashes in class names will be camelized |
1282
- | **`'dashes-only'`** | `string` | Dashes in class names will be camelized, the original class name will be removed from the locals |
1298
+ | Name | Type | Description |
1299
+ | :---------------------: | :------: | :-------------------------------------------------------------------------------------------------- |
1300
+ | **`'as-is'`** | `string` | Class names will be exported as is. |
1301
+ | **`'camel-case'`** | `string` | Class names will be camelCased, but the original class name will not to be removed from the locals. |
1302
+ | **`'camel-case-only'`** | `string` | Class names will be camelCased, and original class name will be removed from the locals. |
1303
+ | **`'dashes'`** | `string` | Only dashes in class names will be camelCased |
1304
+ | **`'dashes-only'`** | `string` | Dashes in class names will be camelCased, the original class name will be removed from the locals |
1283
1305
 
1284
1306
  **file.css**
1285
1307
 
@@ -1379,8 +1401,10 @@ Default: `false`
1379
1401
  Export only locals.
1380
1402
 
1381
1403
  **Useful** when you use **css modules** for pre-rendering (for example SSR).
1404
+
1382
1405
  For pre-rendering with `mini-css-extract-plugin` you should use this option instead of `style-loader!css-loader` **in the pre-rendering bundle**.
1383
- It doesn't embed CSS but only exports the identifier mappings.
1406
+
1407
+ It doesn't embed CSS; it only exports the identifier mappings.
1384
1408
 
1385
1409
  **webpack.config.js**
1386
1410
 
@@ -1422,7 +1446,9 @@ type getJSON = ({
1422
1446
 
1423
1447
  Default: `undefined`
1424
1448
 
1425
- Enables a callback to output the CSS modules mapping JSON. The callback is invoked with an object containing the following:
1449
+ Enables a callback to output the CSS modules mapping JSON.
1450
+
1451
+ The callback is invoked with an object containing the following:
1426
1452
 
1427
1453
  - `resourcePath`: the absolute path of the original resource, e.g., `/foo/bar/baz.module.css`
1428
1454
 
@@ -1440,7 +1466,7 @@ Enables a callback to output the CSS modules mapping JSON. The callback is invok
1440
1466
  ]
1441
1467
  ```
1442
1468
 
1443
- (Note that this will include all imports, not just those relevant to CSS modules.)
1469
+ (Note that this will include all imports, not just those relevant to CSS Modules.)
1444
1470
 
1445
1471
  - `exports`: an array of export objects with exported names and values, e.g.,
1446
1472
 
@@ -1463,10 +1489,9 @@ Enables a callback to output the CSS modules mapping JSON. The callback is invok
1463
1489
  }
1464
1490
  ```
1465
1491
 
1466
- Using `getJSON`, it's possible to output a files with all CSS module mappings.
1467
- In the following example, we use `getJSON` to cache canonical mappings and
1468
- add stand-ins for any composed values (through `composes`), and we use a custom plugin
1469
- to consolidate the values and output them to a file:
1492
+ Using `getJSON`, it's possible to output a file with all CSS module mappings.
1493
+
1494
+ In the following example, we use `getJSON` to cache canonical mappings and add stand-ins for any composed values (through `composes`), and we use a custom plugin to consolidate the values and output them to a file:
1470
1495
 
1471
1496
  **webpack.config.js**
1472
1497
 
@@ -1658,9 +1683,9 @@ type importLoaders = number;
1658
1683
 
1659
1684
  Default: `0`
1660
1685
 
1661
- Allows to enables/disables or setups number of loaders applied before CSS loader for `@import` at-rules, CSS modules and ICSS imports, i.e. `@import`/`composes`/`@value value from './values.css'`/etc.
1686
+ Allows to enables/disables or sets up the number of loaders applied before CSS loader for `@import` at-rules, CSS Modules and ICSS imports, i.e. `@import`/`composes`/`@value value from './values.css'`/etc.
1662
1687
 
1663
- The option `importLoaders` allows you to configure how many loaders before `css-loader` should be applied to `@import`ed resources and CSS modules/ICSS imports.
1688
+ The option `importLoaders` allows you to configure how many loaders before `css-loader` should be applied to `@import`ed resources and CSS Modules/ICSS imports.
1664
1689
 
1665
1690
  **webpack.config.js**
1666
1691
 
@@ -1702,7 +1727,7 @@ type sourceMap = boolean;
1702
1727
 
1703
1728
  Default: depends on the `compiler.devtool` value
1704
1729
 
1705
- By default generation of source maps depends on the [`devtool`](https://webpack.js.org/configuration/devtool/) option. All values enable source map generation except `eval` and `false` value.
1730
+ By default generation of source maps depends on the [`devtool`](https://webpack.js.org/configuration/devtool/) option. All values enable source map generation except `eval` and `false` values.
1706
1731
 
1707
1732
  **webpack.config.js**
1708
1733
 
@@ -1733,9 +1758,10 @@ type esModule = boolean;
1733
1758
  Default: `true`
1734
1759
 
1735
1760
  By default, `css-loader` generates JS modules that use the ES modules syntax.
1761
+
1736
1762
  There are some cases in which using ES modules is beneficial, like in the case of [module concatenation](https://webpack.js.org/plugins/module-concatenation-plugin/) and [tree shaking](https://webpack.js.org/guides/tree-shaking/).
1737
1763
 
1738
- You can enable a CommonJS modules syntax using:
1764
+ You can enable CommonJS module syntax using:
1739
1765
 
1740
1766
  **webpack.config.js**
1741
1767
 
@@ -1766,7 +1792,8 @@ type exportType = "array" | "string" | "css-style-sheet";
1766
1792
  Default: `'array'`
1767
1793
 
1768
1794
  Allows exporting styles as array with modules, string or [constructable stylesheet](https://developers.google.com/web/updates/2019/02/constructable-stylesheets) (i.e. [`CSSStyleSheet`](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet)).
1769
- Default value is `'array'`, i.e. loader exports array of modules with specific API which is used in `style-loader` or other.
1795
+
1796
+ The default value is `'array'`, i.e. loader exports an array of modules with a specific API which is used in `style-loader` or other.
1770
1797
 
1771
1798
  **webpack.config.js**
1772
1799
 
@@ -1823,13 +1850,11 @@ import "./styles.css";
1823
1850
 
1824
1851
  #### `'string'`
1825
1852
 
1826
- > **Warning**
1853
+ > [!WARNING]
1827
1854
  >
1828
- > You should not use [`style-loader`](https://github.com/webpack-contrib/style-loader) or [`mini-css-extract-plugin`](https://github.com/webpack-contrib/mini-css-extract-plugin) with this value.
1829
-
1830
- > **Warning**
1855
+ > You should not use [`style-loader`](https://github.com/webpack/style-loader) or [`mini-css-extract-plugin`](https://github.com/webpack/mini-css-extract-plugin) with this value.
1831
1856
  >
1832
- > The `esModule` option should be enabled if you want to use it with [`CSS modules`](https://github.com/webpack-contrib/css-loader#modules), by default for locals will be used [named export](https://github.com/webpack-contrib/css-loader#namedexport).
1857
+ > The `esModule` option should be enabled if you want to use it with [`CSS modules`](https://github.com/webpack/css-loader#modules). By default for locals [named export](https://github.com/webpack/css-loader#namedexport) will be used.
1833
1858
 
1834
1859
  The default export is `string`.
1835
1860
 
@@ -1858,21 +1883,21 @@ console.log(sheet);
1858
1883
 
1859
1884
  #### `'css-style-sheet'`
1860
1885
 
1861
- > **Warning**
1886
+ > [!WARNING]
1862
1887
  >
1863
1888
  > `@import` rules not yet allowed, more [information](https://web.dev/css-module-scripts/#@import-rules-not-yet-allowed)
1864
1889
 
1865
- > **Warning**
1890
+ > [!WARNING]
1866
1891
  >
1867
- > You don't need [`style-loader`](https://github.com/webpack-contrib/style-loader) anymore, please remove it.
1892
+ > You don't need [`style-loader`](https://github.com/webpack/style-loader) anymore, please remove it.
1868
1893
 
1869
- > **Warning**
1894
+ > [!WARNING]
1870
1895
  >
1871
- > The `esModule` option should be enabled if you want to use it with [`CSS modules`](https://github.com/webpack-contrib/css-loader#modules), by default for locals will be used [named export](https://github.com/webpack-contrib/css-loader#namedexport).
1896
+ > The `esModule` option should be enabled if you want to use it with [`CSS modules`](https://github.com/webpack/css-loader#modules). By default for locals [named export](https://github.com/webpack/css-loader#namedexport) will be used.
1872
1897
 
1873
- > **Warning**
1898
+ > [!WARNING]
1874
1899
  >
1875
- > Source maps are not currently supported in `Chrome` due [bug](https://bugs.chromium.org/p/chromium/issues/detail?id=1174094&q=CSSStyleSheet%20source%20maps&can=2)
1900
+ > Source maps are not currently supported in `Chrome` due to a [bug](https://bugs.chromium.org/p/chromium/issues/detail?id=1174094&q=CSSStyleSheet%20source%20maps&can=2)
1876
1901
 
1877
1902
  The default export is a [constructable stylesheet](https://developers.google.com/web/updates/2019/02/constructable-stylesheets) (i.e. [`CSSStyleSheet`](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet)).
1878
1903
 
@@ -1977,11 +2002,13 @@ module.exports = {
1977
2002
 
1978
2003
  ### Recommend
1979
2004
 
1980
- For `production` builds it's recommended to extract the CSS from your bundle being able to use parallel loading of CSS/JS resources later on.
1981
- This can be achieved by using the [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin), because it creates separate css files.
1982
- For `development` mode (including `webpack-dev-server`) you can use [style-loader](https://github.com/webpack-contrib/style-loader), because it injects CSS into the DOM using multiple `<style></style>` and works faster.
2005
+ For `production` builds, it's recommended to extract the CSS from your bundle being able to use parallel loading of CSS/JS resources later on.
2006
+
2007
+ This can be achieved by using the [mini-css-extract-plugin](https://github.com/webpack/mini-css-extract-plugin), because it creates separate css files.
1983
2008
 
1984
- > **Note**
2009
+ For `development` mode (including `webpack-dev-server`) you can use [style-loader](https://github.com/webpack/style-loader), because it injects CSS into the DOM using multiple `<style></style>` and works faster.
2010
+
2011
+ > [!NOTE]
1985
2012
  >
1986
2013
  > Do not use `style-loader` and `mini-css-extract-plugin` together.
1987
2014
 
@@ -2011,7 +2038,7 @@ module.exports = {
2011
2038
  };
2012
2039
  ```
2013
2040
 
2014
- ### Disable url resolving using the `/* webpackIgnore: true */` comment
2041
+ ### Disable URL resolving using the `/* webpackIgnore: true */` comment
2015
2042
 
2016
2043
  With the help of the `/* webpackIgnore: true */`comment, it is possible to disable sources handling for rules and for individual declarations.
2017
2044
 
@@ -2094,15 +2121,15 @@ module.exports = {
2094
2121
 
2095
2122
  ### Extract
2096
2123
 
2097
- For production builds it's recommended to extract the CSS from your bundle being able to use parallel loading of CSS/JS resources later on.
2124
+ For production builds it's recommended to extract the CSS from your bundle to enable parallel loading of CSS/JS resources later on.
2098
2125
 
2099
- - This can be achieved by using the [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) to extract the CSS when running in production mode.
2126
+ - This can be achieved by using the [mini-css-extract-plugin](https://github.com/webpack/mini-css-extract-plugin) to extract the CSS when running in production mode.
2100
2127
 
2101
- - As an alternative, if seeking better development performance and css outputs that mimic production. [extract-css-chunks-webpack-plugin](https://github.com/faceyspacey/extract-css-chunks-webpack-plugin) offers a hot module reload friendly, extended version of mini-css-extract-plugin. HMR real CSS files in dev, works like mini-css in non-dev
2128
+ - As an alternative, if seeking better development performance and css outputs that mimic production. [extract-css-chunks-webpack-plugin](https://github.com/faceyspacey/extract-css-chunks-webpack-plugin) offers a hot module reload friendly, extended version of mini-css-extract-plugin. HMR real CSS files in dev, works like mini-css in non-dev.
2102
2129
 
2103
- ### Pure CSS, CSS modules and PostCSS
2130
+ ### Pure CSS, CSS Modules and PostCSS
2104
2131
 
2105
- When you have pure CSS (without CSS modules), CSS modules and PostCSS in your project you can use this setup:
2132
+ When you have pure CSS (without CSS modules), CSS modules and PostCSS in your project, you can use this setup:
2106
2133
 
2107
2134
  **webpack.config.js**
2108
2135
 
@@ -2206,8 +2233,9 @@ module.exports = {
2206
2233
 
2207
2234
  ### Separating `Interoperable CSS`-only and `CSS Module` features
2208
2235
 
2209
- The following setup is an example of allowing `Interoperable CSS` features only (such as `:import` and `:export`) without using further `CSS Module` functionality by setting `mode` option for all files that do not match `*.module.scss` naming convention. This is for reference as having `ICSS` features applied to all files was default `css-loader` behavior before v4.
2210
- Meanwhile all files matching `*.module.scss` are treated as `CSS Modules` in this example.
2236
+ The following setup is an example of allowing `Interoperable CSS` features only (such as `:import` and `:export`) without using further `CSS Module` functionality by setting the `mode` option for all files that do not match the `*.module.scss` naming convention. This is for reference, as having `ICSS` features applied to all files was default `css-loader` behavior before v4.
2237
+
2238
+ Meanwhile, all files matching `*.module.scss` are treated as `CSS Modules` in this example.
2211
2239
 
2212
2240
  An example case is assumed where a project requires canvas drawing variables to be synchronized with CSS - canvas drawing uses the same color (set by color name in JavaScript) as HTML background (set by class name in CSS).
2213
2241
 
@@ -2312,9 +2340,11 @@ ctx.fillStyle = `${svars.colorBackgroundCanvas}`;
2312
2340
 
2313
2341
  ## Contributing
2314
2342
 
2315
- Please take a moment to read our contributing guidelines if you haven't yet done so.
2343
+ We welcome all contributions!
2344
+
2345
+ If you are new here, please take a moment to review our contributing guidelines before submitting issues or pull requests.
2316
2346
 
2317
- [CONTRIBUTING](./.github/CONTRIBUTING.md)
2347
+ [CONTRIBUTING](https://github.com/webpack/css-loader?tab=contributing-ov-file#contributing)
2318
2348
 
2319
2349
  ## License
2320
2350
 
@@ -2324,10 +2354,10 @@ Please take a moment to read our contributing guidelines if you haven't yet done
2324
2354
  [npm-url]: https://npmjs.com/package/css-loader
2325
2355
  [node]: https://img.shields.io/node/v/css-loader.svg
2326
2356
  [node-url]: https://nodejs.org
2327
- [tests]: https://github.com/webpack-contrib/css-loader/workflows/css-loader/badge.svg
2328
- [tests-url]: https://github.com/webpack-contrib/css-loader/actions
2329
- [cover]: https://codecov.io/gh/webpack-contrib/css-loader/branch/master/graph/badge.svg
2330
- [cover-url]: https://codecov.io/gh/webpack-contrib/css-loader
2357
+ [tests]: https://github.com/webpack/css-loader/workflows/css-loader/badge.svg
2358
+ [tests-url]: https://github.com/webpack/css-loader/actions
2359
+ [cover]: https://codecov.io/gh/webpack/css-loader/branch/main/graph/badge.svg
2360
+ [cover-url]: https://codecov.io/gh/webpack/css-loader
2331
2361
  [discussion]: https://img.shields.io/github/discussions/webpack/webpack
2332
2362
  [discussion-url]: https://github.com/webpack/webpack/discussions
2333
2363
  [size]: https://packagephobia.now.sh/badge?p=css-loader
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@ var _semver = require("semver");
10
10
  var _options = _interopRequireDefault(require("./options.json"));
11
11
  var _plugins = require("./plugins");
12
12
  var _utils = require("./utils");
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
14
  /*
15
15
  MIT License http://www.opensource.org/licenses/mit-license.php
16
16
  Author Tobias Koppers @sokra
@@ -148,20 +148,7 @@ async function loader(content, map, meta) {
148
148
  });
149
149
  }
150
150
  }
151
- let isTemplateLiteralSupported = false;
152
- if (
153
- // eslint-disable-next-line no-underscore-dangle
154
- this._compilation &&
155
- // eslint-disable-next-line no-underscore-dangle
156
- this._compilation.options &&
157
- // eslint-disable-next-line no-underscore-dangle
158
- this._compilation.options.output &&
159
- // eslint-disable-next-line no-underscore-dangle
160
- this._compilation.options.output.environment &&
161
- // eslint-disable-next-line no-underscore-dangle
162
- this._compilation.options.output.environment.templateLiteral) {
163
- isTemplateLiteralSupported = true;
164
- }
151
+ const isTemplateLiteralSupported = (0, _utils.supportTemplateLiteral)(this);
165
152
  const importCode = (0, _utils.getImportCode)(imports, options);
166
153
  let moduleCode;
167
154
  try {
package/dist/options.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "properties": {
5
5
  "url": {
6
6
  "description": "Allows to enables/disables `url()`/`image-set()` functions handling.",
7
- "link": "https://github.com/webpack-contrib/css-loader#url",
7
+ "link": "https://github.com/webpack/css-loader#url",
8
8
  "anyOf": [
9
9
  {
10
10
  "type": "boolean"
@@ -22,7 +22,7 @@
22
22
  },
23
23
  "import": {
24
24
  "description": "Allows to enables/disables `@import` at-rules handling.",
25
- "link": "https://github.com/webpack-contrib/css-loader#import",
25
+ "link": "https://github.com/webpack/css-loader#import",
26
26
  "anyOf": [
27
27
  {
28
28
  "type": "boolean"
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "modules": {
42
42
  "description": "Allows to enable/disable CSS Modules or ICSS and setup configuration.",
43
- "link": "https://github.com/webpack-contrib/css-loader#modules",
43
+ "link": "https://github.com/webpack/css-loader#modules",
44
44
  "anyOf": [
45
45
  {
46
46
  "type": "boolean"
@@ -54,7 +54,7 @@
54
54
  "properties": {
55
55
  "auto": {
56
56
  "description": "Allows auto enable CSS modules based on filename.",
57
- "link": "https://github.com/webpack-contrib/css-loader#auto",
57
+ "link": "https://github.com/webpack/css-loader#auto",
58
58
  "anyOf": [
59
59
  {
60
60
  "instanceof": "RegExp"
@@ -69,7 +69,7 @@
69
69
  },
70
70
  "mode": {
71
71
  "description": "Setup `mode` option.",
72
- "link": "https://github.com/webpack-contrib/css-loader#mode",
72
+ "link": "https://github.com/webpack/css-loader#mode",
73
73
  "anyOf": [
74
74
  {
75
75
  "enum": ["local", "global", "pure", "icss"]
@@ -81,47 +81,47 @@
81
81
  },
82
82
  "localIdentName": {
83
83
  "description": "Allows to configure the generated local ident name.",
84
- "link": "https://github.com/webpack-contrib/css-loader#localidentname",
84
+ "link": "https://github.com/webpack/css-loader#localidentname",
85
85
  "type": "string",
86
86
  "minLength": 1
87
87
  },
88
88
  "localIdentContext": {
89
89
  "description": "Allows to redefine basic loader context for local ident name.",
90
- "link": "https://github.com/webpack-contrib/css-loader#localidentcontext",
90
+ "link": "https://github.com/webpack/css-loader#localidentcontext",
91
91
  "type": "string",
92
92
  "minLength": 1
93
93
  },
94
94
  "localIdentHashSalt": {
95
95
  "description": "Allows to add custom hash to generate more unique classes.",
96
- "link": "https://github.com/webpack-contrib/css-loader#localidenthashsalt",
96
+ "link": "https://github.com/webpack/css-loader#localidenthashsalt",
97
97
  "type": "string",
98
98
  "minLength": 1
99
99
  },
100
100
  "localIdentHashFunction": {
101
101
  "description": "Allows to specify hash function to generate classes.",
102
- "link": "https://github.com/webpack-contrib/css-loader#localidenthashfunction",
102
+ "link": "https://github.com/webpack/css-loader#localidenthashfunction",
103
103
  "type": "string",
104
104
  "minLength": 1
105
105
  },
106
106
  "localIdentHashDigest": {
107
107
  "description": "Allows to specify hash digest to generate classes.",
108
- "link": "https://github.com/webpack-contrib/css-loader#localidenthashdigest",
108
+ "link": "https://github.com/webpack/css-loader#localidenthashdigest",
109
109
  "type": "string",
110
110
  "minLength": 1
111
111
  },
112
112
  "localIdentHashDigestLength": {
113
113
  "description": "Allows to specify hash digest length to generate classes.",
114
- "link": "https://github.com/webpack-contrib/css-loader#localidenthashdigestlength",
114
+ "link": "https://github.com/webpack/css-loader#localidenthashdigestlength",
115
115
  "type": "number"
116
116
  },
117
117
  "hashStrategy": {
118
118
  "description": "Allows to specify should localName be used when computing the hash.",
119
- "link": "https://github.com/webpack-contrib/css-loader#hashstrategy",
119
+ "link": "https://github.com/webpack/css-loader#hashstrategy",
120
120
  "enum": ["resource-path-and-local-name", "minimal-subset"]
121
121
  },
122
122
  "localIdentRegExp": {
123
123
  "description": "Allows to specify custom RegExp for local ident name.",
124
- "link": "https://github.com/webpack-contrib/css-loader#localidentregexp",
124
+ "link": "https://github.com/webpack/css-loader#localidentregexp",
125
125
  "anyOf": [
126
126
  {
127
127
  "type": "string",
@@ -134,22 +134,22 @@
134
134
  },
135
135
  "getLocalIdent": {
136
136
  "description": "Allows to specify a function to generate the classname.",
137
- "link": "https://github.com/webpack-contrib/css-loader#getlocalident",
137
+ "link": "https://github.com/webpack/css-loader#getlocalident",
138
138
  "instanceof": "Function"
139
139
  },
140
140
  "namedExport": {
141
141
  "description": "Enables/disables ES modules named export for locals.",
142
- "link": "https://github.com/webpack-contrib/css-loader#namedexport",
142
+ "link": "https://github.com/webpack/css-loader#namedexport",
143
143
  "type": "boolean"
144
144
  },
145
145
  "exportGlobals": {
146
146
  "description": "Allows to export names from global class or id, so you can use that as local name.",
147
- "link": "https://github.com/webpack-contrib/css-loader#exportglobals",
147
+ "link": "https://github.com/webpack/css-loader#exportglobals",
148
148
  "type": "boolean"
149
149
  },
150
150
  "exportLocalsConvention": {
151
151
  "description": "Style of exported classnames.",
152
- "link": "https://github.com/webpack-contrib/css-loader#localsconvention",
152
+ "link": "https://github.com/webpack/css-loader#localsconvention",
153
153
  "anyOf": [
154
154
  {
155
155
  "enum": [
@@ -171,12 +171,12 @@
171
171
  },
172
172
  "exportOnlyLocals": {
173
173
  "description": "Export only locals.",
174
- "link": "https://github.com/webpack-contrib/css-loader#exportonlylocals",
174
+ "link": "https://github.com/webpack/css-loader#exportonlylocals",
175
175
  "type": "boolean"
176
176
  },
177
177
  "getJSON": {
178
178
  "description": "Allows outputting of CSS modules mapping through a callback.",
179
- "link": "https://github.com/webpack-contrib/css-loader#getJSON",
179
+ "link": "https://github.com/webpack/css-loader#getJSON",
180
180
  "instanceof": "Function"
181
181
  }
182
182
  }
@@ -185,12 +185,12 @@
185
185
  },
186
186
  "sourceMap": {
187
187
  "description": "Allows to enable/disable source maps.",
188
- "link": "https://github.com/webpack-contrib/css-loader#sourcemap",
188
+ "link": "https://github.com/webpack/css-loader#sourcemap",
189
189
  "type": "boolean"
190
190
  },
191
191
  "importLoaders": {
192
192
  "description": "Allows enables/disables or setups number of loaders applied before CSS loader for `@import`/CSS Modules and ICSS imports.",
193
- "link": "https://github.com/webpack-contrib/css-loader#importloaders",
193
+ "link": "https://github.com/webpack/css-loader#importloaders",
194
194
  "anyOf": [
195
195
  {
196
196
  "type": "boolean"
@@ -205,12 +205,12 @@
205
205
  },
206
206
  "esModule": {
207
207
  "description": "Use the ES modules syntax.",
208
- "link": "https://github.com/webpack-contrib/css-loader#esmodule",
208
+ "link": "https://github.com/webpack/css-loader#esmodule",
209
209
  "type": "boolean"
210
210
  },
211
211
  "exportType": {
212
212
  "description": "Allows exporting styles as array with modules, string or constructable stylesheet (i.e. `CSSStyleSheet`).",
213
- "link": "https://github.com/webpack-contrib/css-loader#exporttype",
213
+ "link": "https://github.com/webpack/css-loader#exporttype",
214
214
  "enum": ["array", "string", "css-style-sheet"]
215
215
  }
216
216
  },
@@ -24,4 +24,4 @@ Object.defineProperty(exports, "urlParser", {
24
24
  var _postcssImportParser = _interopRequireDefault(require("./postcss-import-parser"));
25
25
  var _postcssIcssParser = _interopRequireDefault(require("./postcss-icss-parser"));
26
26
  var _postcssUrlParser = _interopRequireDefault(require("./postcss-url-parser"));
27
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -6,26 +6,33 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
8
8
  var _utils = require("../utils");
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
- function parseNode(atRule, key, options) {
11
- // Convert only top-level @import
12
- if (atRule.parent.type !== "root") {
13
- return;
14
- }
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ function isIgnoredAfterName(atRule) {
15
11
  if (atRule.raws && atRule.raws.afterName && atRule.raws.afterName.trim().length > 0) {
16
12
  const lastCommentIndex = atRule.raws.afterName.lastIndexOf("/*");
17
13
  const matched = atRule.raws.afterName.slice(lastCommentIndex).match(_utils.WEBPACK_IGNORE_COMMENT_REGEXP);
18
14
  if (matched && matched[2] === "true") {
19
- return;
15
+ return true;
20
16
  }
21
17
  }
18
+ return false;
19
+ }
20
+ function isIgnoredPrevNode(atRule) {
22
21
  const prevNode = atRule.prev();
23
22
  if (prevNode && prevNode.type === "comment") {
24
23
  const matched = prevNode.text.match(_utils.WEBPACK_IGNORE_COMMENT_REGEXP);
25
24
  if (matched && matched[2] === "true") {
26
- return;
25
+ return true;
27
26
  }
28
27
  }
28
+ return false;
29
+ }
30
+ function parseNode(atRule, key, options) {
31
+ // Convert only top-level @import
32
+ if (atRule.parent.type !== "root") {
33
+ return;
34
+ }
35
+ const isIgnored = isIgnoredAfterName(atRule) || isIgnoredPrevNode(atRule);
29
36
 
30
37
  // Nodes do not exists - `@import url('http://') :root {}`
31
38
  if (atRule.nodes) {
@@ -61,10 +68,14 @@ function parseNode(atRule, key, options) {
61
68
  url = isStringValue ? paramsNodes[0].nodes[0].value : _postcssValueParser.default.stringify(paramsNodes[0].nodes);
62
69
  }
63
70
  url = (0, _utils.normalizeUrl)(url, isStringValue);
64
- const {
65
- requestable,
66
- needResolve
67
- } = (0, _utils.isURLRequestable)(url, options);
71
+ let requestable = false;
72
+ let needResolve = false;
73
+ if (!isIgnored) {
74
+ ({
75
+ requestable,
76
+ needResolve
77
+ } = (0, _utils.isURLRequestable)(url, options));
78
+ }
68
79
  let prefix;
69
80
  if (requestable && needResolve) {
70
81
  const queryParts = url.split("!");
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
8
8
  var _utils = require("../utils");
9
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
10
  const isUrlFunc = /url/i;
11
11
  const isImageSetFunc = /^(?:-webkit-)?image-set$/i;
12
12
  const needParseDeclaration = /(?:url|(?:-webkit-)?image-set)\(/i;
package/dist/utils.js CHANGED
@@ -27,6 +27,7 @@ exports.shouldUseModulesPlugins = shouldUseModulesPlugins;
27
27
  exports.shouldUseURLPlugin = shouldUseURLPlugin;
28
28
  exports.sort = sort;
29
29
  exports.stringifyRequest = stringifyRequest;
30
+ exports.supportTemplateLiteral = supportTemplateLiteral;
30
31
  exports.syntaxErrorFactory = syntaxErrorFactory;
31
32
  exports.warningFactory = warningFactory;
32
33
  var _url = require("url");
@@ -35,7 +36,7 @@ var _postcssModulesValues = _interopRequireDefault(require("postcss-modules-valu
35
36
  var _postcssModulesLocalByDefault = _interopRequireDefault(require("postcss-modules-local-by-default"));
36
37
  var _postcssModulesExtractImports = _interopRequireDefault(require("postcss-modules-extract-imports"));
37
38
  var _postcssModulesScope = _interopRequireDefault(require("postcss-modules-scope"));
38
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
39
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
39
40
  /*
40
41
  MIT License http://www.opensource.org/licenses/mit-license.php
41
42
  Author Tobias Koppers @sokra
@@ -282,8 +283,10 @@ function defaultGetLocalIdent(loaderContext, localIdentName, localName, options)
282
283
  }
283
284
  let localIdentHash = "";
284
285
  for (let tier = 0; localIdentHash.length < hashDigestLength; tier++) {
286
+ const hash = (loaderContext.utils.createHash ||
287
+ // TODO remove in the next major release
285
288
  // eslint-disable-next-line no-underscore-dangle
286
- const hash = loaderContext._compiler.webpack.util.createHash(hashFunction);
289
+ loaderContext._compiler.webpack.util.createHash)(hashFunction);
287
290
  if (hashSalt) {
288
291
  hash.update(hashSalt);
289
292
  }
@@ -427,11 +430,6 @@ function getModulesOptions(rawOptions, esModule, exportType, loaderContext) {
427
430
  auto
428
431
  } = rawModulesOptions);
429
432
  }
430
-
431
- // eslint-disable-next-line no-underscore-dangle
432
- const {
433
- outputOptions
434
- } = loaderContext._compilation;
435
433
  const needNamedExport = exportType === "css-style-sheet" || exportType === "string";
436
434
  const namedExport = typeof rawModulesOptions.namedExport !== "undefined" ? rawModulesOptions.namedExport : needNamedExport || esModule;
437
435
  const exportLocalsConvention = typeof rawModulesOptions.exportLocalsConvention !== "undefined" ? rawModulesOptions.exportLocalsConvention : namedExport ? "as-is" : "camel-case-only";
@@ -441,10 +439,23 @@ function getModulesOptions(rawOptions, esModule, exportType, loaderContext) {
441
439
  exportGlobals: false,
442
440
  localIdentName: "[hash:base64]",
443
441
  localIdentContext: loaderContext.rootContext,
444
- localIdentHashSalt: outputOptions.hashSalt,
445
- localIdentHashFunction: outputOptions.hashFunction,
446
- localIdentHashDigest: outputOptions.hashDigest,
447
- localIdentHashDigestLength: outputOptions.hashDigestLength,
442
+ // eslint-disable-next-line no-underscore-dangle
443
+ localIdentHashSalt: loaderContext.hashSalt ||
444
+ // TODO remove in the next major release
445
+ // eslint-disable-next-line no-underscore-dangle
446
+ loaderContext._compilation.outputOptions.hashSalt,
447
+ localIdentHashFunction: loaderContext.hashFunction ||
448
+ // TODO remove in the next major release
449
+ // eslint-disable-next-line no-underscore-dangle
450
+ loaderContext._compilation.outputOptions.hashFunction,
451
+ localIdentHashDigest: loaderContext.hashDigest ||
452
+ // TODO remove in the next major release
453
+ // eslint-disable-next-line no-underscore-dangle
454
+ loaderContext._compilation.outputOptions.hashDigest,
455
+ localIdentHashDigestLength: loaderContext.hashDigestLength ||
456
+ // TODO remove in the next major release
457
+ // eslint-disable-next-line no-underscore-dangle
458
+ loaderContext._compilation.outputOptions.hashDigestLength,
448
459
  // eslint-disable-next-line no-undefined
449
460
  localIdentRegExp: undefined,
450
461
  // eslint-disable-next-line no-undefined
@@ -837,7 +848,7 @@ function dashesCamelCase(str) {
837
848
  return str.replace(/-+(\w)/g, (match, firstLetter) => firstLetter.toUpperCase());
838
849
  }
839
850
  const validIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/u;
840
- const keywords = new Set(["abstract", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "debugger", "default", "delete", "do", "double", "else", "enum", "export", "extends", "false", "final", "finally", "float", "for", "function", "goto", "if", "implements", "import", "in", "instanceof", "int", "interface", "long", "native", "new", "null", "package", "private", "protected", "public", "return", "short", "static", "super", "switch", "synchronized", "this", "throw", "throws", "transient", "true", "try", "typeof", "var", "void", "volatile", "while", "with"]);
851
+ const keywords = new Set(["abstract", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "debugger", "default", "delete", "do", "double", "else", "enum", "export", "extends", "false", "final", "finally", "float", "for", "function", "goto", "if", "implements", "import", "in", "instanceof", "int", "interface", "long", "native", "new", "null", "package", "private", "protected", "public", "return", "short", "static", "super", "switch", "synchronized", "this", "throw", "throws", "transient", "true", "try", "typeof", "var", "void", "volatile", "while", "with", "module"]);
841
852
  function getExportCode(exports, replacements, icssPluginUsed, options, isTemplateLiteralSupported) {
842
853
  let code = "// Exports\n";
843
854
  if (icssPluginUsed) {
@@ -1033,4 +1044,25 @@ function syntaxErrorFactory(error) {
1033
1044
  });
1034
1045
  obj.stack = null;
1035
1046
  return obj;
1047
+ }
1048
+ function supportTemplateLiteral(loaderContext) {
1049
+ if (loaderContext.environment && loaderContext.environment.templateLiteral) {
1050
+ return true;
1051
+ }
1052
+
1053
+ // TODO remove in the next major release
1054
+ if (
1055
+ // eslint-disable-next-line no-underscore-dangle
1056
+ loaderContext._compilation &&
1057
+ // eslint-disable-next-line no-underscore-dangle
1058
+ loaderContext._compilation.options &&
1059
+ // eslint-disable-next-line no-underscore-dangle
1060
+ loaderContext._compilation.options.output &&
1061
+ // eslint-disable-next-line no-underscore-dangle
1062
+ loaderContext._compilation.options.output.environment &&
1063
+ // eslint-disable-next-line no-underscore-dangle
1064
+ loaderContext._compilation.options.output.environment.templateLiteral) {
1065
+ return true;
1066
+ }
1067
+ return false;
1036
1068
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "css-loader",
3
- "version": "7.1.1",
3
+ "version": "7.1.3",
4
4
  "description": "css loader module for webpack",
5
5
  "license": "MIT",
6
- "repository": "webpack-contrib/css-loader",
6
+ "repository": "webpack/css-loader",
7
7
  "author": "Tobias Koppers @sokra",
8
- "homepage": "https://github.com/webpack-contrib/css-loader",
9
- "bugs": "https://github.com/webpack-contrib/css-loader/issues",
8
+ "homepage": "https://github.com/webpack/css-loader",
9
+ "bugs": "https://github.com/webpack/css-loader/issues",
10
10
  "funding": {
11
11
  "type": "opencollective",
12
12
  "url": "https://opencollective.com/webpack"
@@ -22,7 +22,7 @@
22
22
  "prebuild": "npm run clean",
23
23
  "build": "cross-env NODE_ENV=production babel src -d dist --copy-files",
24
24
  "postbuild": "npm run validate:runtime",
25
- "commitlint": "commitlint --from=master",
25
+ "commitlint": "commitlint --from=main",
26
26
  "security": "npm audit --production",
27
27
  "lint:prettier": "prettier --cache --list-different .",
28
28
  "lint:js": "eslint --cache .",
@@ -56,51 +56,51 @@
56
56
  },
57
57
  "dependencies": {
58
58
  "icss-utils": "^5.1.0",
59
- "postcss": "^8.4.33",
59
+ "postcss": "^8.4.40",
60
60
  "postcss-modules-extract-imports": "^3.1.0",
61
61
  "postcss-modules-local-by-default": "^4.0.5",
62
62
  "postcss-modules-scope": "^3.2.0",
63
63
  "postcss-modules-values": "^4.0.0",
64
64
  "postcss-value-parser": "^4.2.0",
65
- "semver": "^7.5.4"
65
+ "semver": "^7.6.3"
66
66
  },
67
67
  "devDependencies": {
68
- "@babel/cli": "^7.23.4",
69
- "@babel/core": "^7.23.7",
70
- "@babel/preset-env": "^7.23.7",
71
- "@commitlint/cli": "^19.2.1",
72
- "@commitlint/config-conventional": "^19.1.0",
68
+ "@babel/cli": "^7.24.8",
69
+ "@babel/core": "^7.25.2",
70
+ "@babel/preset-env": "^7.25.3",
71
+ "@commitlint/cli": "^19.3.0",
72
+ "@commitlint/config-conventional": "^19.2.2",
73
73
  "@webpack-contrib/eslint-config-webpack": "^3.0.0",
74
- "babel-jest": "^29.7.0",
74
+ "babel-jest": "^30.0.0",
75
75
  "cross-env": "^7.0.3",
76
- "cspell": "^8.6.1",
76
+ "cspell": "^8.13.1",
77
77
  "del-cli": "^5.1.0",
78
- "es-check": "^7.1.0",
78
+ "es-check": "^7.2.1",
79
79
  "eslint": "^8.54.0",
80
80
  "eslint-config-prettier": "^9.1.0",
81
81
  "eslint-plugin-import": "^2.29.0",
82
82
  "file-loader": "^6.2.0",
83
- "husky": "^9.0.11",
84
- "jest": "^29.7.0",
85
- "jest-environment-jsdom": "^29.7.0",
83
+ "husky": "^9.1.4",
84
+ "jest": "^30.0.0",
85
+ "jest-environment-jsdom": "^30.0.0",
86
86
  "less": "^4.2.0",
87
87
  "less-loader": "^12.2.0",
88
- "lint-staged": "^15.2.2",
89
- "memfs": "^4.8.1",
90
- "mini-css-extract-plugin": "^2.7.5",
88
+ "lint-staged": "^15.2.8",
89
+ "memfs": "^4.11.1",
90
+ "mini-css-extract-plugin": "^2.9.0",
91
91
  "npm-run-all": "^4.1.5",
92
92
  "postcss-loader": "^8.1.1",
93
- "postcss-preset-env": "^9.5.4",
94
- "prettier": "^3.2.5",
95
- "sass": "^1.69.7",
96
- "sass-loader": "^14.1.1",
93
+ "postcss-preset-env": "^9.6.0",
94
+ "prettier": "^3.3.3",
95
+ "sass": "^1.77.8",
96
+ "sass-loader": "^14.2.1",
97
97
  "standard-version": "^9.5.0",
98
98
  "strip-ansi": "^6.0.0",
99
99
  "style-loader": "^3.3.4",
100
100
  "stylus": "^0.63.0",
101
101
  "stylus-loader": "^8.1.0",
102
102
  "url-loader": "^4.1.1",
103
- "webpack": "^5.89.0"
103
+ "webpack": "^5.93.0"
104
104
  },
105
105
  "keywords": [
106
106
  "webpack",