@@ -49,6 +49,8 @@ class MiniCssExtractPlugin {
49
49
identifier,
50
50
identifierIndex,
51
51
content,
52
+ layer,
53
+ supports,
52
54
media,
53
55
sourceMap,
54
56
assets,
@@ -61,6 +63,8 @@ class MiniCssExtractPlugin {
61
63
this . _identifier = identifier ;
62
64
this . _identifierIndex = identifierIndex ;
63
65
this . content = content ;
66
+ this . layer = layer ;
67
+ this . supports = supports ;
64
68
this . media = media ;
65
69
this . sourceMap = sourceMap ;
66
70
this . assets = assets ;
@@ -108,6 +112,8 @@ class MiniCssExtractPlugin {
108
112
updateCacheModule ( module ) {
109
113
if (
110
114
this . content !== module . content ||
115
+ this . layer !== module . layer ||
116
+ this . supports !== module . supports ||
111
117
this . media !== module . media ||
112
118
this . sourceMap !== module . sourceMap ||
113
119
this . assets !== module . assets ||
@@ -116,6 +122,8 @@ class MiniCssExtractPlugin {
116
122
this . _needBuild = true ;
117
123
118
124
this . content = module . content ;
125
+ this . layer = module . layer ;
126
+ this . supports = module . supports ;
119
127
this . media = module . media ;
120
128
this . sourceMap = module . sourceMap ;
121
129
this . assets = module . assets ;
@@ -150,6 +158,12 @@ class MiniCssExtractPlugin {
150
158
const hash = webpack . util . createHash ( hashFunction ) ;
151
159
152
160
hash . update ( this . content ) ;
161
+
162
+ if ( this . layer ) {
163
+ hash . update ( this . layer ) ;
164
+ }
165
+
166
+ hash . update ( this . supports || "" ) ;
153
167
hash . update ( this . media || "" ) ;
154
168
hash . update ( this . sourceMap || "" ) ;
155
169
@@ -169,6 +183,8 @@ class MiniCssExtractPlugin {
169
183
write ( this . _identifier ) ;
170
184
write ( this . _identifierIndex ) ;
171
185
write ( this . content ) ;
186
+ write ( this . layer ) ;
187
+ write ( this . supports ) ;
172
188
write ( this . media ) ;
173
189
write ( this . sourceMap ) ;
174
190
write ( this . assets ) ;
@@ -203,16 +219,19 @@ class MiniCssExtractPlugin {
203
219
const identifier = read ( ) ;
204
220
const identifierIndex = read ( ) ;
205
221
const content = read ( ) ;
222
+ const layer = read ( ) ;
223
+ const supports = read ( ) ;
206
224
const media = read ( ) ;
207
225
const sourceMap = read ( ) ;
208
226
const assets = read ( ) ;
209
227
const assetsInfo = read ( ) ;
210
-
211
228
const dep = new CssModule ( {
212
229
context : contextModule ,
213
230
identifier,
214
231
identifierIndex,
215
232
content,
233
+ layer,
234
+ supports,
216
235
media,
217
236
sourceMap,
218
237
assets,
@@ -239,7 +258,7 @@ class MiniCssExtractPlugin {
239
258
// eslint-disable-next-line no-shadow
240
259
class CssDependency extends webpack . Dependency {
241
260
constructor (
242
- { identifier, content, media, sourceMap } ,
261
+ { identifier, content, layer , supports , media, sourceMap } ,
243
262
context ,
244
263
identifierIndex
245
264
) {
@@ -248,6 +267,8 @@ class MiniCssExtractPlugin {
248
267
this . identifier = identifier ;
249
268
this . identifierIndex = identifierIndex ;
250
269
this . content = content ;
270
+ this . layer = layer ;
271
+ this . supports = supports ;
251
272
this . media = media ;
252
273
this . sourceMap = sourceMap ;
253
274
this . context = context ;
@@ -271,6 +292,8 @@ class MiniCssExtractPlugin {
271
292
272
293
write ( this . identifier ) ;
273
294
write ( this . content ) ;
295
+ write ( this . layer ) ;
296
+ write ( this . supports ) ;
274
297
write ( this . media ) ;
275
298
write ( this . sourceMap ) ;
276
299
write ( this . context ) ;
@@ -302,6 +325,8 @@ class MiniCssExtractPlugin {
302
325
{
303
326
identifier : read ( ) ,
304
327
content : read ( ) ,
328
+ layer : read ( ) ,
329
+ supports : read ( ) ,
305
330
media : read ( ) ,
306
331
sourceMap : read ( ) ,
307
332
} ,
@@ -1024,10 +1049,22 @@ class MiniCssExtractPlugin {
1024
1049
source . add ( header ) ;
1025
1050
}
1026
1051
1052
+ if ( module . supports ) {
1053
+ source . add ( `@supports (${ module . supports } ) {\n` ) ;
1054
+ }
1055
+
1027
1056
if ( module . media ) {
1028
1057
source . add ( `@media ${ module . media } {\n` ) ;
1029
1058
}
1030
1059
1060
+ const needLayer = typeof module . layer !== "undefined" ;
1061
+
1062
+ if ( needLayer ) {
1063
+ source . add (
1064
+ `@layer${ module . layer . length > 0 ? ` ${ module . layer } ` : "" } {\n`
1065
+ ) ;
1066
+ }
1067
+
1031
1068
const { path : filename } = compilation . getPathWithInfo (
1032
1069
filenameTemplate ,
1033
1070
pathData
@@ -1056,9 +1093,17 @@ class MiniCssExtractPlugin {
1056
1093
1057
1094
source . add ( "\n" ) ;
1058
1095
1096
+ if ( needLayer ) {
1097
+ source . add ( "}\n" ) ;
1098
+ }
1099
+
1059
1100
if ( module . media ) {
1060
1101
source . add ( "}\n" ) ;
1061
1102
}
1103
+
1104
+ if ( module . supports ) {
1105
+ source . add ( "}\n" ) ;
1106
+ }
1062
1107
}
1063
1108
}
1064
1109
0 commit comments