@@ -169,15 +169,11 @@ module.exports = {
169
169
test: / \. style. js$ / ,
170
170
use: [
171
171
" style-loader" ,
172
- {
173
- loader: " css-loader" ,
174
- },
172
+ { loader: " css-loader" },
175
173
{
176
174
loader: " postcss-loader" ,
177
175
options: {
178
- postcssOptions: {
179
- parser: " postcss-js" ,
180
- },
176
+ postcssOptions: { parser: " postcss-js" },
181
177
execute: true ,
182
178
},
183
179
},
@@ -195,8 +191,8 @@ See the file [`./src/config.d.ts`](./src/config.d.ts).
195
191
Type:
196
192
197
193
``` ts
198
- import type { Config as PostCSSConfig } from " postcss-load-config" ;
199
- import type { LoaderContext } from " webpack" ;
194
+ import { type Config as PostCSSConfig } from " postcss-load-config" ;
195
+ import { type LoaderContext } from " webpack" ;
200
196
201
197
type PostCSSLoaderContext = LoaderContext <PostCSSConfig >;
202
198
@@ -270,10 +266,7 @@ module.exports = {
270
266
loader: " postcss-loader" ,
271
267
options: {
272
268
postcssOptions: {
273
- plugins: {
274
- " postcss-import" : {},
275
- " postcss-short" : { prefix: " x" },
276
- },
269
+ plugins: { " postcss-import" : {}, " postcss-short" : { prefix: " x" } },
277
270
},
278
271
},
279
272
},
@@ -286,6 +279,8 @@ Setup `syntax`:
286
279
287
280
** webpack.config.js**
288
281
282
+ <!-- eslint-skip -->
283
+
289
284
``` js
290
285
module .exports = {
291
286
module: {
@@ -311,6 +306,8 @@ Setup `parser`:
311
306
312
307
** webpack.config.js**
313
308
309
+ <!-- eslint-skip -->
310
+
314
311
``` js
315
312
module .exports = {
316
313
module: {
@@ -338,6 +335,8 @@ Setup `stringifier`:
338
335
339
336
** webpack.config.js**
340
337
338
+ <!-- eslint-skip -->
339
+
341
340
``` js
342
341
const Midas = require (" midas" );
343
342
const midas = new Midas ();
@@ -528,12 +527,7 @@ module.exports = {
528
527
test: / \. css$ / ,
529
528
use: [
530
529
" style-loader" ,
531
- {
532
- loader: " css-loader" ,
533
- options: {
534
- importLoaders: 1 ,
535
- },
536
- },
530
+ { loader: " css-loader" , options: { importLoaders: 1 } },
537
531
" postcss-loader" ,
538
532
],
539
533
},
@@ -555,11 +549,7 @@ module.exports = {
555
549
{
556
550
test: / \. css$ / i ,
557
551
loader: " postcss-loader" ,
558
- options: {
559
- postcssOptions: {
560
- config: false ,
561
- },
562
- },
552
+ options: { postcssOptions: { config: false } },
563
553
},
564
554
],
565
555
},
@@ -573,7 +563,7 @@ Allows to specify the path to the config file.
573
563
** webpack.config.js**
574
564
575
565
``` js
576
- const path = require (" path" );
566
+ const path = require (" node: path" );
577
567
578
568
module .exports = {
579
569
module: {
@@ -738,17 +728,10 @@ module.exports = {
738
728
test: / \. sss$ / i ,
739
729
use: [
740
730
" style-loader" ,
741
- {
742
- loader: " css-loader" ,
743
- options: { importLoaders: 1 },
744
- },
731
+ { loader: " css-loader" , options: { importLoaders: 1 } },
745
732
{
746
733
loader: " postcss-loader" ,
747
- options: {
748
- postcssOptions: {
749
- parser: " sugarss" ,
750
- },
751
- },
734
+ options: { postcssOptions: { parser: " sugarss" } },
752
735
},
753
736
],
754
737
},
@@ -777,10 +760,7 @@ module.exports = {
777
760
test: / \. css$ / i ,
778
761
use: [
779
762
" style-loader" ,
780
- {
781
- loader: " css-loader" ,
782
- options: { importLoaders: 1 },
783
- },
763
+ { loader: " css-loader" , options: { importLoaders: 1 } },
784
764
{
785
765
loader: " postcss-loader" ,
786
766
options: {
@@ -825,10 +805,7 @@ module.exports = {
825
805
test: / \. css$ / i ,
826
806
use: [
827
807
" style-loader" ,
828
- {
829
- loader: " css-loader" ,
830
- options: { importLoaders: 1 },
831
- },
808
+ { loader: " css-loader" , options: { importLoaders: 1 } },
832
809
{
833
810
loader: " postcss-loader" ,
834
811
options: {
@@ -870,10 +847,7 @@ module.exports = {
870
847
" style-loader" ,
871
848
{
872
849
loader: " css-loader" ,
873
- options: {
874
- modules: true ,
875
- importLoaders: 1 ,
876
- },
850
+ options: { modules: true , importLoaders: 1 },
877
851
},
878
852
" postcss-loader" ,
879
853
],
@@ -905,18 +879,11 @@ module.exports = {
905
879
test: / \. style. js$ / ,
906
880
use: [
907
881
" style-loader" ,
908
- {
909
- loader: " css-loader" ,
910
- options: {
911
- importLoaders: 2 ,
912
- },
913
- },
882
+ { loader: " css-loader" , options: { importLoaders: 2 } },
914
883
{
915
884
loader: " postcss-loader" ,
916
885
options: {
917
- postcssOptions: {
918
- parser: " postcss-js" ,
919
- },
886
+ postcssOptions: { parser: " postcss-js" },
920
887
execute: true ,
921
888
},
922
889
},
@@ -934,13 +901,7 @@ As result you will be able to write styles in the following way:
934
901
import colors from " ./styles/colors" ;
935
902
936
903
export default {
937
- " .menu" : {
938
- color: colors .main ,
939
- height: 25 ,
940
- " &_link" : {
941
- color: " white" ,
942
- },
943
- },
904
+ " .menu" : { color: colors .main , height: 25 , " &_link" : { color: " white" } },
944
905
};
945
906
```
946
907
@@ -1001,18 +962,16 @@ The message should contain the following fields:
1001
962
** webpack.config.js**
1002
963
1003
964
``` js
1004
- const postcssCustomPlugin = (opts = {}) => {
1005
- return {
1006
- postcssPlugin: " postcss-custom-plugin" ,
1007
- Once : (root , { result }) => {
1008
- result .messages .push ({
1009
- type: " asset" ,
1010
- file: " sprite.svg" ,
1011
- content: " <svg>...</svg>" ,
1012
- });
1013
- },
1014
- };
1015
- };
965
+ const postcssCustomPlugin = (opts = {}) => ({
966
+ postcssPlugin: " postcss-custom-plugin" ,
967
+ Once : (root , { result }) => {
968
+ result .messages .push ({
969
+ type: " asset" ,
970
+ file: " sprite.svg" ,
971
+ content: " <svg>...</svg>" ,
972
+ });
973
+ },
974
+ });
1016
975
1017
976
module .exports = {
1018
977
module: {
@@ -1024,11 +983,7 @@ module.exports = {
1024
983
" css-loader" ,
1025
984
{
1026
985
loader: " postcss-loader" ,
1027
- options: {
1028
- postcssOptions: {
1029
- plugins: [postcssCustomPlugin ()],
1030
- },
1031
- },
986
+ options: { postcssOptions: { plugins: [postcssCustomPlugin ()] } },
1032
987
},
1033
988
],
1034
989
},
@@ -1055,19 +1010,17 @@ The message should contain the following fields:
1055
1010
** webpack.config.js**
1056
1011
1057
1012
``` js
1058
- const path = require (" path" );
1059
-
1060
- const postcssCustomPlugin = (opts = {}) => {
1061
- return {
1062
- postcssPlugin: " postcss-custom-plugin" ,
1063
- Once : (root , { result }) => {
1064
- result .messages .push ({
1065
- type: " dependency" ,
1066
- file: path .resolve (__dirname , " path" , " to" , " file" ),
1067
- });
1068
- },
1069
- };
1070
- };
1013
+ const path = require (" node:path" );
1014
+
1015
+ const postcssCustomPlugin = (opts = {}) => ({
1016
+ postcssPlugin: " postcss-custom-plugin" ,
1017
+ Once : (root , { result }) => {
1018
+ result .messages .push ({
1019
+ type: " dependency" ,
1020
+ file: path .resolve (__dirname , " path" , " to" , " file" ),
1021
+ });
1022
+ },
1023
+ });
1071
1024
1072
1025
module .exports = {
1073
1026
module: {
@@ -1079,11 +1032,7 @@ module.exports = {
1079
1032
" css-loader" ,
1080
1033
{
1081
1034
loader: " postcss-loader" ,
1082
- options: {
1083
- postcssOptions: {
1084
- plugins: [postcssCustomPlugin ()],
1085
- },
1086
- },
1035
+ options: { postcssOptions: { plugins: [postcssCustomPlugin ()] } },
1087
1036
},
1088
1037
],
1089
1038
},
@@ -1099,7 +1048,7 @@ module.exports = {
1099
1048
** webpack.config.js**
1100
1049
1101
1050
``` js
1102
- const path = require (" path" );
1051
+ const path = require (" node: path" );
1103
1052
1104
1053
module .exports = {
1105
1054
module: {
@@ -1145,20 +1094,19 @@ module.exports = (api) => ({
1145
1094
Register a file dependency using ` loaderContext.addDependency ` :
1146
1095
1147
1096
``` js
1148
- const path = require (" path" );
1149
-
1150
- const postcssCustomPlugin = (opts = {}) => {
1151
- return {
1152
- postcssPlugin: " postcss-custom-plugin" ,
1153
- Once : (root , { result }) => {
1154
- opts .loaderContext .addDependency (
1155
- path .resolve (__dirname , " path" , " to" , " file" ),
1156
- );
1157
- },
1158
- };
1159
- };
1097
+ const path = require (" node:path" );
1098
+
1099
+ const postcssCustomPlugin = (opts = {}) => ({
1100
+ postcssPlugin: " postcss-custom-plugin" ,
1101
+ Once : (root , { result }) => {
1102
+ opts .loaderContext .addDependency (
1103
+ path .resolve (__dirname , " path" , " to" , " file" ),
1104
+ );
1105
+ },
1106
+ });
1160
1107
1161
1108
postcssCustomPlugin .postcss = true ;
1109
+
1162
1110
module .exports = postcssCustomPlugin;
1163
1111
```
1164
1112
0 commit comments