@@ -49,6 +49,8 @@ class MiniCssExtractPlugin {
4949 identifier,
5050 identifierIndex,
5151 content,
52+ layer,
53+ supports,
5254 media,
5355 sourceMap,
5456 assets,
@@ -61,6 +63,8 @@ class MiniCssExtractPlugin {
6163 this . _identifier = identifier ;
6264 this . _identifierIndex = identifierIndex ;
6365 this . content = content ;
66+ this . layer = layer ;
67+ this . supports = supports ;
6468 this . media = media ;
6569 this . sourceMap = sourceMap ;
6670 this . assets = assets ;
@@ -108,6 +112,8 @@ class MiniCssExtractPlugin {
108112 updateCacheModule ( module ) {
109113 if (
110114 this . content !== module . content ||
115+ this . layer !== module . layer ||
116+ this . supports !== module . supports ||
111117 this . media !== module . media ||
112118 this . sourceMap !== module . sourceMap ||
113119 this . assets !== module . assets ||
@@ -116,6 +122,8 @@ class MiniCssExtractPlugin {
116122 this . _needBuild = true ;
117123
118124 this . content = module . content ;
125+ this . layer = module . layer ;
126+ this . supports = module . supports ;
119127 this . media = module . media ;
120128 this . sourceMap = module . sourceMap ;
121129 this . assets = module . assets ;
@@ -150,6 +158,12 @@ class MiniCssExtractPlugin {
150158 const hash = webpack . util . createHash ( hashFunction ) ;
151159
152160 hash . update ( this . content ) ;
161+
162+ if ( this . layer ) {
163+ hash . update ( this . layer ) ;
164+ }
165+
166+ hash . update ( this . supports || "" ) ;
153167 hash . update ( this . media || "" ) ;
154168 hash . update ( this . sourceMap || "" ) ;
155169
@@ -169,6 +183,8 @@ class MiniCssExtractPlugin {
169183 write ( this . _identifier ) ;
170184 write ( this . _identifierIndex ) ;
171185 write ( this . content ) ;
186+ write ( this . layer ) ;
187+ write ( this . supports ) ;
172188 write ( this . media ) ;
173189 write ( this . sourceMap ) ;
174190 write ( this . assets ) ;
@@ -203,16 +219,19 @@ class MiniCssExtractPlugin {
203219 const identifier = read ( ) ;
204220 const identifierIndex = read ( ) ;
205221 const content = read ( ) ;
222+ const layer = read ( ) ;
223+ const supports = read ( ) ;
206224 const media = read ( ) ;
207225 const sourceMap = read ( ) ;
208226 const assets = read ( ) ;
209227 const assetsInfo = read ( ) ;
210-
211228 const dep = new CssModule ( {
212229 context : contextModule ,
213230 identifier,
214231 identifierIndex,
215232 content,
233+ layer,
234+ supports,
216235 media,
217236 sourceMap,
218237 assets,
@@ -239,7 +258,7 @@ class MiniCssExtractPlugin {
239258 // eslint-disable-next-line no-shadow
240259 class CssDependency extends webpack . Dependency {
241260 constructor (
242- { identifier, content, media, sourceMap } ,
261+ { identifier, content, layer , supports , media, sourceMap } ,
243262 context ,
244263 identifierIndex
245264 ) {
@@ -248,6 +267,8 @@ class MiniCssExtractPlugin {
248267 this . identifier = identifier ;
249268 this . identifierIndex = identifierIndex ;
250269 this . content = content ;
270+ this . layer = layer ;
271+ this . supports = supports ;
251272 this . media = media ;
252273 this . sourceMap = sourceMap ;
253274 this . context = context ;
@@ -271,6 +292,8 @@ class MiniCssExtractPlugin {
271292
272293 write ( this . identifier ) ;
273294 write ( this . content ) ;
295+ write ( this . layer ) ;
296+ write ( this . supports ) ;
274297 write ( this . media ) ;
275298 write ( this . sourceMap ) ;
276299 write ( this . context ) ;
@@ -302,6 +325,8 @@ class MiniCssExtractPlugin {
302325 {
303326 identifier : read ( ) ,
304327 content : read ( ) ,
328+ layer : read ( ) ,
329+ supports : read ( ) ,
305330 media : read ( ) ,
306331 sourceMap : read ( ) ,
307332 } ,
@@ -1024,10 +1049,22 @@ class MiniCssExtractPlugin {
10241049 source . add ( header ) ;
10251050 }
10261051
1052+ if ( module . supports ) {
1053+ source . add ( `@supports (${ module . supports } ) {\n` ) ;
1054+ }
1055+
10271056 if ( module . media ) {
10281057 source . add ( `@media ${ module . media } {\n` ) ;
10291058 }
10301059
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+
10311068 const { path : filename } = compilation . getPathWithInfo (
10321069 filenameTemplate ,
10331070 pathData
@@ -1056,9 +1093,17 @@ class MiniCssExtractPlugin {
10561093
10571094 source . add ( "\n" ) ;
10581095
1096+ if ( needLayer ) {
1097+ source . add ( "}\n" ) ;
1098+ }
1099+
10591100 if ( module . media ) {
10601101 source . add ( "}\n" ) ;
10611102 }
1103+
1104+ if ( module . supports ) {
1105+ source . add ( "}\n" ) ;
1106+ }
10621107 }
10631108 }
10641109
0 commit comments