css-loader 5.0.1 → 5.0.2
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/CHANGELOG.md +7 -0
- package/README.md +117 -85
- package/dist/CssSyntaxError.js +3 -3
- package/dist/Warning.js +2 -2
- package/dist/cjs.js +1 -1
- package/dist/index.js +17 -17
- package/dist/plugins/postcss-icss-parser.js +4 -4
- package/dist/plugins/postcss-import-parser.js +10 -10
- package/dist/plugins/postcss-url-parser.js +16 -16
- package/dist/runtime/api.js +3 -3
- package/dist/runtime/cssWithMappingToString.js +4 -4
- package/dist/runtime/getUrl.js +2 -2
- package/dist/utils.js +77 -79
- package/package.json +20 -20
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [5.0.2](https://github.com/webpack-contrib/css-loader/compare/v5.0.1...v5.0.2) (2021-02-08)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* pass query with hash to other loaders ([#1261](https://github.com/webpack-contrib/css-loader/issues/1261)) ([729a314](https://github.com/webpack-contrib/css-loader/commit/729a314529cd0607c374b07bdf425337f9a778d4))
|
|
11
|
+
|
|
5
12
|
### [5.0.1](https://github.com/webpack-contrib/css-loader/compare/v5.0.0...v5.0.1) (2020-11-04)
|
|
6
13
|
|
|
7
14
|
|
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ Then add the plugin to your `webpack` config. For example:
|
|
|
32
32
|
**file.js**
|
|
33
33
|
|
|
34
34
|
```js
|
|
35
|
-
import css from
|
|
35
|
+
import css from "file.css";
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
**webpack.config.js**
|
|
@@ -43,13 +43,15 @@ module.exports = {
|
|
|
43
43
|
rules: [
|
|
44
44
|
{
|
|
45
45
|
test: /\.css$/i,
|
|
46
|
-
use: [
|
|
46
|
+
use: ["style-loader", "css-loader"],
|
|
47
47
|
},
|
|
48
48
|
],
|
|
49
49
|
},
|
|
50
50
|
};
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
+
**Only for webpack v4:**
|
|
54
|
+
|
|
53
55
|
Good loaders for requiring your assets are the [file-loader](https://github.com/webpack/file-loader) and the [url-loader](https://github.com/webpack/url-loader) which you should specify in your config (see [below](https://github.com/webpack-contrib/css-loader#assets)).
|
|
54
56
|
|
|
55
57
|
And run `webpack` via your preferred method.
|
|
@@ -66,7 +68,7 @@ module.exports = {
|
|
|
66
68
|
rules: [
|
|
67
69
|
{
|
|
68
70
|
test: /\.css$/i,
|
|
69
|
-
use: [
|
|
71
|
+
use: ["to-string-loader", "css-loader"],
|
|
70
72
|
},
|
|
71
73
|
],
|
|
72
74
|
},
|
|
@@ -76,7 +78,7 @@ module.exports = {
|
|
|
76
78
|
or
|
|
77
79
|
|
|
78
80
|
```js
|
|
79
|
-
const css = require(
|
|
81
|
+
const css = require("./test.css").toString();
|
|
80
82
|
|
|
81
83
|
console.log(css); // {String}
|
|
82
84
|
```
|
|
@@ -97,9 +99,9 @@ module.exports = {
|
|
|
97
99
|
{
|
|
98
100
|
test: /\.css$/i,
|
|
99
101
|
use: [
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
102
|
+
"handlebars-loader", // handlebars loader expects raw resource string
|
|
103
|
+
"extract-loader",
|
|
104
|
+
"css-loader",
|
|
103
105
|
],
|
|
104
106
|
},
|
|
105
107
|
],
|
|
@@ -157,7 +159,7 @@ module.exports = {
|
|
|
157
159
|
rules: [
|
|
158
160
|
{
|
|
159
161
|
test: /\.css$/i,
|
|
160
|
-
loader:
|
|
162
|
+
loader: "css-loader",
|
|
161
163
|
options: {
|
|
162
164
|
url: true,
|
|
163
165
|
},
|
|
@@ -179,13 +181,13 @@ module.exports = {
|
|
|
179
181
|
rules: [
|
|
180
182
|
{
|
|
181
183
|
test: /\.css$/i,
|
|
182
|
-
loader:
|
|
184
|
+
loader: "css-loader",
|
|
183
185
|
options: {
|
|
184
186
|
url: (url, resourcePath) => {
|
|
185
187
|
// resourcePath - path to css file
|
|
186
188
|
|
|
187
189
|
// Don't handle `img.png` urls
|
|
188
|
-
if (url.includes(
|
|
190
|
+
if (url.includes("img.png")) {
|
|
189
191
|
return false;
|
|
190
192
|
}
|
|
191
193
|
|
|
@@ -238,7 +240,7 @@ module.exports = {
|
|
|
238
240
|
rules: [
|
|
239
241
|
{
|
|
240
242
|
test: /\.css$/i,
|
|
241
|
-
loader:
|
|
243
|
+
loader: "css-loader",
|
|
242
244
|
options: {
|
|
243
245
|
import: true,
|
|
244
246
|
},
|
|
@@ -260,13 +262,13 @@ module.exports = {
|
|
|
260
262
|
rules: [
|
|
261
263
|
{
|
|
262
264
|
test: /\.css$/i,
|
|
263
|
-
loader:
|
|
265
|
+
loader: "css-loader",
|
|
264
266
|
options: {
|
|
265
267
|
import: (url, media, resourcePath) => {
|
|
266
268
|
// resourcePath - path to css file
|
|
267
269
|
|
|
268
270
|
// Don't handle `style.css` import
|
|
269
|
-
if (url.includes(
|
|
271
|
+
if (url.includes("style.css")) {
|
|
270
272
|
return false;
|
|
271
273
|
}
|
|
272
274
|
|
|
@@ -298,7 +300,7 @@ module.exports = {
|
|
|
298
300
|
rules: [
|
|
299
301
|
{
|
|
300
302
|
test: /\.css$/i,
|
|
301
|
-
loader:
|
|
303
|
+
loader: "css-loader",
|
|
302
304
|
options: {
|
|
303
305
|
modules: true,
|
|
304
306
|
},
|
|
@@ -362,8 +364,8 @@ The loader replaces local selectors with unique identifiers. The chosen unique i
|
|
|
362
364
|
|
|
363
365
|
```js
|
|
364
366
|
exports.locals = {
|
|
365
|
-
className:
|
|
366
|
-
subClass:
|
|
367
|
+
className: "_23_aKvs-b8bW2Vg3fwHozO",
|
|
368
|
+
subClass: "_13LGdX8RMStbBE9w-t0gZ1",
|
|
367
369
|
};
|
|
368
370
|
```
|
|
369
371
|
|
|
@@ -391,8 +393,8 @@ This doesn't result in any change to the CSS itself but exports multiple classna
|
|
|
391
393
|
|
|
392
394
|
```js
|
|
393
395
|
exports.locals = {
|
|
394
|
-
className:
|
|
395
|
-
subClass:
|
|
396
|
+
className: "_23_aKvs-b8bW2Vg3fwHozO",
|
|
397
|
+
subClass: "_13LGdX8RMStbBE9w-t0gZ1 _23_aKvs-b8bW2Vg3fwHozO",
|
|
396
398
|
};
|
|
397
399
|
```
|
|
398
400
|
|
|
@@ -415,14 +417,14 @@ To import a local classname from another module.
|
|
|
415
417
|
|
|
416
418
|
```css
|
|
417
419
|
:local(.continueButton) {
|
|
418
|
-
composes: button from
|
|
420
|
+
composes: button from "library/button.css";
|
|
419
421
|
background: red;
|
|
420
422
|
}
|
|
421
423
|
```
|
|
422
424
|
|
|
423
425
|
```css
|
|
424
426
|
:local(.nameEdit) {
|
|
425
|
-
composes: edit highlight from
|
|
427
|
+
composes: edit highlight from "./edit.css";
|
|
426
428
|
background: red;
|
|
427
429
|
}
|
|
428
430
|
```
|
|
@@ -431,8 +433,8 @@ To import from multiple modules use multiple `composes:` rules.
|
|
|
431
433
|
|
|
432
434
|
```css
|
|
433
435
|
:local(.className) {
|
|
434
|
-
composes: edit hightlight from
|
|
435
|
-
composes: button from
|
|
436
|
+
composes: edit hightlight from "./edit.css";
|
|
437
|
+
composes: button from "module/button.css";
|
|
436
438
|
composes: classFromThisModule;
|
|
437
439
|
background: red;
|
|
438
440
|
}
|
|
@@ -477,7 +479,7 @@ module.exports = {
|
|
|
477
479
|
rules: [
|
|
478
480
|
{
|
|
479
481
|
test: /\.css$/i,
|
|
480
|
-
loader:
|
|
482
|
+
loader: "css-loader",
|
|
481
483
|
options: {
|
|
482
484
|
modules: true,
|
|
483
485
|
},
|
|
@@ -499,10 +501,10 @@ module.exports = {
|
|
|
499
501
|
rules: [
|
|
500
502
|
{
|
|
501
503
|
test: /\.css$/i,
|
|
502
|
-
loader:
|
|
504
|
+
loader: "css-loader",
|
|
503
505
|
options: {
|
|
504
506
|
// Using `local` value has same effect like using `modules: true`
|
|
505
|
-
modules:
|
|
507
|
+
modules: "global",
|
|
506
508
|
},
|
|
507
509
|
},
|
|
508
510
|
],
|
|
@@ -522,18 +524,18 @@ module.exports = {
|
|
|
522
524
|
rules: [
|
|
523
525
|
{
|
|
524
526
|
test: /\.css$/i,
|
|
525
|
-
loader:
|
|
527
|
+
loader: "css-loader",
|
|
526
528
|
options: {
|
|
527
529
|
modules: {
|
|
528
|
-
compileType:
|
|
529
|
-
mode:
|
|
530
|
+
compileType: "module",
|
|
531
|
+
mode: "local",
|
|
530
532
|
auto: true,
|
|
531
533
|
exportGlobals: true,
|
|
532
|
-
localIdentName:
|
|
533
|
-
localIdentContext: path.resolve(__dirname,
|
|
534
|
-
localIdentHashPrefix:
|
|
534
|
+
localIdentName: "[path][name]__[local]--[hash:base64:5]",
|
|
535
|
+
localIdentContext: path.resolve(__dirname, "src"),
|
|
536
|
+
localIdentHashPrefix: "my-custom-hash",
|
|
535
537
|
namedExport: true,
|
|
536
|
-
exportLocalsConvention:
|
|
538
|
+
exportLocalsConvention: "camelCase",
|
|
537
539
|
exportOnlyLocals: false,
|
|
538
540
|
},
|
|
539
541
|
},
|
|
@@ -563,10 +565,10 @@ module.exports = {
|
|
|
563
565
|
rules: [
|
|
564
566
|
{
|
|
565
567
|
test: /\.css$/i,
|
|
566
|
-
loader:
|
|
568
|
+
loader: "css-loader",
|
|
567
569
|
options: {
|
|
568
570
|
modules: {
|
|
569
|
-
compileType:
|
|
571
|
+
compileType: "icss",
|
|
570
572
|
},
|
|
571
573
|
},
|
|
572
574
|
},
|
|
@@ -597,7 +599,7 @@ module.exports = {
|
|
|
597
599
|
rules: [
|
|
598
600
|
{
|
|
599
601
|
test: /\.css$/i,
|
|
600
|
-
loader:
|
|
602
|
+
loader: "css-loader",
|
|
601
603
|
options: {
|
|
602
604
|
modules: {
|
|
603
605
|
auto: true,
|
|
@@ -621,7 +623,7 @@ module.exports = {
|
|
|
621
623
|
rules: [
|
|
622
624
|
{
|
|
623
625
|
test: /\.css$/i,
|
|
624
|
-
loader:
|
|
626
|
+
loader: "css-loader",
|
|
625
627
|
options: {
|
|
626
628
|
modules: {
|
|
627
629
|
auto: /\.custom-module\.\w+$/i,
|
|
@@ -645,10 +647,10 @@ module.exports = {
|
|
|
645
647
|
rules: [
|
|
646
648
|
{
|
|
647
649
|
test: /\.css$/i,
|
|
648
|
-
loader:
|
|
650
|
+
loader: "css-loader",
|
|
649
651
|
options: {
|
|
650
652
|
modules: {
|
|
651
|
-
auto: (resourcePath) => resourcePath.endsWith(
|
|
653
|
+
auto: (resourcePath) => resourcePath.endsWith(".custom-module.css"),
|
|
652
654
|
},
|
|
653
655
|
},
|
|
654
656
|
},
|
|
@@ -676,10 +678,10 @@ module.exports = {
|
|
|
676
678
|
rules: [
|
|
677
679
|
{
|
|
678
680
|
test: /\.css$/i,
|
|
679
|
-
loader:
|
|
681
|
+
loader: "css-loader",
|
|
680
682
|
options: {
|
|
681
683
|
modules: {
|
|
682
|
-
mode:
|
|
684
|
+
mode: "global",
|
|
683
685
|
},
|
|
684
686
|
},
|
|
685
687
|
},
|
|
@@ -702,20 +704,20 @@ module.exports = {
|
|
|
702
704
|
rules: [
|
|
703
705
|
{
|
|
704
706
|
test: /\.css$/i,
|
|
705
|
-
loader:
|
|
707
|
+
loader: "css-loader",
|
|
706
708
|
options: {
|
|
707
709
|
modules: {
|
|
708
710
|
// Callback must return "local", "global", or "pure" values
|
|
709
711
|
mode: (resourcePath) => {
|
|
710
712
|
if (/pure.css$/i.test(resourcePath)) {
|
|
711
|
-
return
|
|
713
|
+
return "pure";
|
|
712
714
|
}
|
|
713
715
|
|
|
714
716
|
if (/global.css$/i.test(resourcePath)) {
|
|
715
|
-
return
|
|
717
|
+
return "global";
|
|
716
718
|
}
|
|
717
719
|
|
|
718
|
-
return
|
|
720
|
+
return "local";
|
|
719
721
|
},
|
|
720
722
|
},
|
|
721
723
|
},
|
|
@@ -750,10 +752,10 @@ module.exports = {
|
|
|
750
752
|
rules: [
|
|
751
753
|
{
|
|
752
754
|
test: /\.css$/i,
|
|
753
|
-
loader:
|
|
755
|
+
loader: "css-loader",
|
|
754
756
|
options: {
|
|
755
757
|
modules: {
|
|
756
|
-
localIdentName:
|
|
758
|
+
localIdentName: "[path][name]__[local]--[hash:base64:5]",
|
|
757
759
|
},
|
|
758
760
|
},
|
|
759
761
|
},
|
|
@@ -777,10 +779,10 @@ module.exports = {
|
|
|
777
779
|
rules: [
|
|
778
780
|
{
|
|
779
781
|
test: /\.css$/i,
|
|
780
|
-
loader:
|
|
782
|
+
loader: "css-loader",
|
|
781
783
|
options: {
|
|
782
784
|
modules: {
|
|
783
|
-
localIdentContext: path.resolve(__dirname,
|
|
785
|
+
localIdentContext: path.resolve(__dirname, "src"),
|
|
784
786
|
},
|
|
785
787
|
},
|
|
786
788
|
},
|
|
@@ -804,10 +806,10 @@ module.exports = {
|
|
|
804
806
|
rules: [
|
|
805
807
|
{
|
|
806
808
|
test: /\.css$/i,
|
|
807
|
-
loader:
|
|
809
|
+
loader: "css-loader",
|
|
808
810
|
options: {
|
|
809
811
|
modules: {
|
|
810
|
-
localIdentHashPrefix:
|
|
812
|
+
localIdentHashPrefix: "hash",
|
|
811
813
|
},
|
|
812
814
|
},
|
|
813
815
|
},
|
|
@@ -829,7 +831,7 @@ module.exports = {
|
|
|
829
831
|
rules: [
|
|
830
832
|
{
|
|
831
833
|
test: /\.css$/i,
|
|
832
|
-
loader:
|
|
834
|
+
loader: "css-loader",
|
|
833
835
|
options: {
|
|
834
836
|
modules: {
|
|
835
837
|
localIdentRegExp: /page-(.*)\.css/i,
|
|
@@ -859,11 +861,11 @@ module.exports = {
|
|
|
859
861
|
rules: [
|
|
860
862
|
{
|
|
861
863
|
test: /\.css$/i,
|
|
862
|
-
loader:
|
|
864
|
+
loader: "css-loader",
|
|
863
865
|
options: {
|
|
864
866
|
modules: {
|
|
865
867
|
getLocalIdent: (context, localIdentName, localName, options) => {
|
|
866
|
-
return
|
|
868
|
+
return "whatever_random_class_name";
|
|
867
869
|
},
|
|
868
870
|
},
|
|
869
871
|
},
|
|
@@ -898,7 +900,7 @@ Enables/disables ES modules named export for locals.
|
|
|
898
900
|
**index.js**
|
|
899
901
|
|
|
900
902
|
```js
|
|
901
|
-
import { fooBaz, bar } from
|
|
903
|
+
import { fooBaz, bar } from "./styles.css";
|
|
902
904
|
|
|
903
905
|
console.log(fooBaz, bar);
|
|
904
906
|
```
|
|
@@ -913,7 +915,7 @@ module.exports = {
|
|
|
913
915
|
rules: [
|
|
914
916
|
{
|
|
915
917
|
test: /\.css$/i,
|
|
916
|
-
loader:
|
|
918
|
+
loader: "css-loader",
|
|
917
919
|
options: {
|
|
918
920
|
esModule: true,
|
|
919
921
|
modules: {
|
|
@@ -941,7 +943,7 @@ module.exports = {
|
|
|
941
943
|
rules: [
|
|
942
944
|
{
|
|
943
945
|
test: /\.css$/i,
|
|
944
|
-
loader:
|
|
946
|
+
loader: "css-loader",
|
|
945
947
|
options: {
|
|
946
948
|
modules: {
|
|
947
949
|
exportGlobals: true,
|
|
@@ -982,7 +984,7 @@ By default, the exported JSON keys mirror the class names (i.e `asIs` value).
|
|
|
982
984
|
**file.js**
|
|
983
985
|
|
|
984
986
|
```js
|
|
985
|
-
import { className } from
|
|
987
|
+
import { className } from "file.css";
|
|
986
988
|
```
|
|
987
989
|
|
|
988
990
|
**webpack.config.js**
|
|
@@ -993,10 +995,11 @@ module.exports = {
|
|
|
993
995
|
rules: [
|
|
994
996
|
{
|
|
995
997
|
test: /\.css$/i,
|
|
996
|
-
loader:
|
|
998
|
+
loader: "css-loader",
|
|
997
999
|
options: {
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
+
modules: {
|
|
1001
|
+
exportLocalsConvention: "camelCase",
|
|
1002
|
+
},
|
|
1000
1003
|
},
|
|
1001
1004
|
},
|
|
1002
1005
|
],
|
|
@@ -1023,7 +1026,7 @@ module.exports = {
|
|
|
1023
1026
|
rules: [
|
|
1024
1027
|
{
|
|
1025
1028
|
test: /\.css$/i,
|
|
1026
|
-
loader:
|
|
1029
|
+
loader: "css-loader",
|
|
1027
1030
|
options: {
|
|
1028
1031
|
modules: {
|
|
1029
1032
|
exportOnlyLocals: true,
|
|
@@ -1050,7 +1053,7 @@ module.exports = {
|
|
|
1050
1053
|
rules: [
|
|
1051
1054
|
{
|
|
1052
1055
|
test: /\.css$/i,
|
|
1053
|
-
loader:
|
|
1056
|
+
loader: "css-loader",
|
|
1054
1057
|
options: {
|
|
1055
1058
|
sourceMap: true,
|
|
1056
1059
|
},
|
|
@@ -1078,9 +1081,9 @@ module.exports = {
|
|
|
1078
1081
|
{
|
|
1079
1082
|
test: /\.css$/i,
|
|
1080
1083
|
use: [
|
|
1081
|
-
|
|
1084
|
+
"style-loader",
|
|
1082
1085
|
{
|
|
1083
|
-
loader:
|
|
1086
|
+
loader: "css-loader",
|
|
1084
1087
|
options: {
|
|
1085
1088
|
importLoaders: 2,
|
|
1086
1089
|
// 0 => no loaders (default);
|
|
@@ -1088,8 +1091,8 @@ module.exports = {
|
|
|
1088
1091
|
// 2 => postcss-loader, sass-loader
|
|
1089
1092
|
},
|
|
1090
1093
|
},
|
|
1091
|
-
|
|
1092
|
-
|
|
1094
|
+
"postcss-loader",
|
|
1095
|
+
"sass-loader",
|
|
1093
1096
|
],
|
|
1094
1097
|
},
|
|
1095
1098
|
],
|
|
@@ -1117,7 +1120,7 @@ module.exports = {
|
|
|
1117
1120
|
rules: [
|
|
1118
1121
|
{
|
|
1119
1122
|
test: /\.css$/i,
|
|
1120
|
-
loader:
|
|
1123
|
+
loader: "css-loader",
|
|
1121
1124
|
options: {
|
|
1122
1125
|
esModule: false,
|
|
1123
1126
|
},
|
|
@@ -1133,6 +1136,8 @@ module.exports = {
|
|
|
1133
1136
|
|
|
1134
1137
|
The following `webpack.config.js` can load CSS files, embed small PNG/JPG/GIF/SVG images as well as fonts as [Data URLs](https://tools.ietf.org/html/rfc2397) and copy larger files to the output directory.
|
|
1135
1138
|
|
|
1139
|
+
**For webpack v5:**
|
|
1140
|
+
|
|
1136
1141
|
**webpack.config.js**
|
|
1137
1142
|
|
|
1138
1143
|
```js
|
|
@@ -1141,11 +1146,33 @@ module.exports = {
|
|
|
1141
1146
|
rules: [
|
|
1142
1147
|
{
|
|
1143
1148
|
test: /\.css$/i,
|
|
1144
|
-
use: [
|
|
1149
|
+
use: ["style-loader", "css-loader"],
|
|
1145
1150
|
},
|
|
1146
1151
|
{
|
|
1147
1152
|
test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/i,
|
|
1148
|
-
|
|
1153
|
+
// More information here https://webpack.js.org/guides/asset-modules/
|
|
1154
|
+
type: "asset",
|
|
1155
|
+
},
|
|
1156
|
+
],
|
|
1157
|
+
},
|
|
1158
|
+
};
|
|
1159
|
+
```
|
|
1160
|
+
|
|
1161
|
+
**For webpack v4:**
|
|
1162
|
+
|
|
1163
|
+
**webpack.config.js**
|
|
1164
|
+
|
|
1165
|
+
```js
|
|
1166
|
+
module.exports = {
|
|
1167
|
+
module: {
|
|
1168
|
+
rules: [
|
|
1169
|
+
{
|
|
1170
|
+
test: /\.css$/i,
|
|
1171
|
+
use: ["style-loader", "css-loader"],
|
|
1172
|
+
},
|
|
1173
|
+
{
|
|
1174
|
+
test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/i,
|
|
1175
|
+
loader: "url-loader",
|
|
1149
1176
|
options: {
|
|
1150
1177
|
limit: 8192,
|
|
1151
1178
|
},
|
|
@@ -1179,34 +1206,39 @@ module.exports = {
|
|
|
1179
1206
|
// For Less - /\.((c|le)ss)$/i,
|
|
1180
1207
|
test: /\.((c|sa|sc)ss)$/i,
|
|
1181
1208
|
use: [
|
|
1182
|
-
|
|
1209
|
+
"style-loader",
|
|
1183
1210
|
{
|
|
1184
|
-
loader:
|
|
1211
|
+
loader: "css-loader",
|
|
1185
1212
|
options: {
|
|
1186
1213
|
// Run `postcss-loader` on each CSS `@import`, do not forget that `sass-loader` compile non CSS `@import`'s into a single file
|
|
1187
1214
|
// If you need run `sass-loader` and `postcss-loader` on each CSS `@import` please set it to `2`
|
|
1188
1215
|
importLoaders: 1,
|
|
1189
|
-
// Automatically enable css modules for files satisfying `/\.module\.\w+$/i` RegExp.
|
|
1190
|
-
modules: { auto: true },
|
|
1191
1216
|
},
|
|
1192
1217
|
},
|
|
1193
1218
|
{
|
|
1194
|
-
loader:
|
|
1219
|
+
loader: "postcss-loader",
|
|
1195
1220
|
options: { plugins: () => [postcssPresetEnv({ stage: 0 })] },
|
|
1196
1221
|
},
|
|
1197
1222
|
// Can be `less-loader`
|
|
1198
1223
|
{
|
|
1199
|
-
loader:
|
|
1224
|
+
loader: "sass-loader",
|
|
1200
1225
|
},
|
|
1201
1226
|
],
|
|
1202
1227
|
},
|
|
1228
|
+
// For webpack v5
|
|
1203
1229
|
{
|
|
1204
1230
|
test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/i,
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
limit: 8192,
|
|
1208
|
-
},
|
|
1231
|
+
// More information here https://webpack.js.org/guides/asset-modules/
|
|
1232
|
+
type: "asset",
|
|
1209
1233
|
},
|
|
1234
|
+
// For webpack v4
|
|
1235
|
+
// {
|
|
1236
|
+
// test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/i,
|
|
1237
|
+
// loader: "url-loader",
|
|
1238
|
+
// options: {
|
|
1239
|
+
// limit: 8192,
|
|
1240
|
+
// },
|
|
1241
|
+
// },
|
|
1210
1242
|
],
|
|
1211
1243
|
},
|
|
1212
1244
|
};
|
|
@@ -1230,15 +1262,15 @@ module.exports = {
|
|
|
1230
1262
|
rules: [
|
|
1231
1263
|
{
|
|
1232
1264
|
test: /\.css$/i,
|
|
1233
|
-
use: [
|
|
1265
|
+
use: ["style-loader", "css-loader"],
|
|
1234
1266
|
},
|
|
1235
1267
|
],
|
|
1236
1268
|
},
|
|
1237
1269
|
resolve: {
|
|
1238
1270
|
alias: {
|
|
1239
|
-
|
|
1271
|
+
"/assets/unresolved/img.png": path.resolve(
|
|
1240
1272
|
__dirname,
|
|
1241
|
-
|
|
1273
|
+
"assets/real-path-to-img/img.png"
|
|
1242
1274
|
),
|
|
1243
1275
|
},
|
|
1244
1276
|
},
|
|
@@ -1326,7 +1358,7 @@ $colorBackground: red;
|
|
|
1326
1358
|
File treated as `CSS Module`.
|
|
1327
1359
|
|
|
1328
1360
|
```scss
|
|
1329
|
-
@import
|
|
1361
|
+
@import "variables.scss";
|
|
1330
1362
|
.componentClass {
|
|
1331
1363
|
background-color: $colorBackground;
|
|
1332
1364
|
}
|
|
@@ -1337,8 +1369,8 @@ File treated as `CSS Module`.
|
|
|
1337
1369
|
Using both `CSS Module` functionality as well as SCSS variables directly in JavaScript.
|
|
1338
1370
|
|
|
1339
1371
|
```jsx
|
|
1340
|
-
import svars from
|
|
1341
|
-
import styles from
|
|
1372
|
+
import svars from "variables.scss";
|
|
1373
|
+
import styles from "Component.module.scss";
|
|
1342
1374
|
|
|
1343
1375
|
// Render DOM with CSS modules class name
|
|
1344
1376
|
// <div className={styles.componentClass}>
|
package/dist/CssSyntaxError.js
CHANGED
|
@@ -14,16 +14,16 @@ class CssSyntaxError extends Error {
|
|
|
14
14
|
column,
|
|
15
15
|
file
|
|
16
16
|
} = error;
|
|
17
|
-
this.name =
|
|
17
|
+
this.name = "CssSyntaxError"; // Based on https://github.com/postcss/postcss/blob/master/lib/css-syntax-error.es6#L132
|
|
18
18
|
// We don't need `plugin` and `file` properties.
|
|
19
19
|
|
|
20
20
|
this.message = `${this.name}\n\n`;
|
|
21
21
|
|
|
22
|
-
if (typeof line !==
|
|
22
|
+
if (typeof line !== "undefined") {
|
|
23
23
|
this.message += `(${line}:${column}) `;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
this.message += file ? `${file} ` :
|
|
26
|
+
this.message += file ? `${file} ` : "<css input> ";
|
|
27
27
|
this.message += `${reason}`;
|
|
28
28
|
const code = error.showSourceCode();
|
|
29
29
|
|
package/dist/Warning.js
CHANGED
|
@@ -13,12 +13,12 @@ class Warning extends Error {
|
|
|
13
13
|
line,
|
|
14
14
|
column
|
|
15
15
|
} = warning;
|
|
16
|
-
this.name =
|
|
16
|
+
this.name = "Warning"; // Based on https://github.com/postcss/postcss/blob/master/lib/warning.es6#L74
|
|
17
17
|
// We don't need `plugin` properties.
|
|
18
18
|
|
|
19
19
|
this.message = `${this.name}\n\n`;
|
|
20
20
|
|
|
21
|
-
if (typeof line !==
|
|
21
|
+
if (typeof line !== "undefined") {
|
|
22
22
|
this.message += `(${line}:${column}) `;
|
|
23
23
|
}
|
|
24
24
|
|
package/dist/cjs.js
CHANGED