File tree Expand file tree Collapse file tree 6 files changed +82
-2
lines changed
test/cases/at-import-external-with-media Expand file tree Collapse file tree 6 files changed +82
-2
lines changed Original file line number Diff line number Diff line change @@ -1368,11 +1368,32 @@ class MiniCssExtractPlugin {
13681368
13691369 // HACK for IE
13701370 // http://stackoverflow.com/a/14676665/1458162
1371- if ( module . media ) {
1371+ if (
1372+ module . media ||
1373+ module . supports ||
1374+ typeof module . layer !== "undefined"
1375+ ) {
1376+ let atImportExtra = "" ;
1377+
1378+ const needLayer = typeof module . layer !== "undefined" ;
1379+
1380+ if ( needLayer ) {
1381+ atImportExtra +=
1382+ module . layer . length > 0 ? ` layer(${ module . layer } )` : " layer" ;
1383+ }
1384+
1385+ if ( module . supports ) {
1386+ atImportExtra += ` supports(${ module . supports } )` ;
1387+ }
1388+
1389+ if ( module . media ) {
1390+ atImportExtra += ` ${ module . media } ` ;
1391+ }
1392+
13721393 // insert media into the @import
13731394 // this is rar
13741395 // TODO improve this and parse the CSS to support multiple medias
1375- content = content . replace ( / ; | \s * $ / , `${ module . media } ;` ) ;
1396+ content = content . replace ( / ; | \s * $ / , `${ atImportExtra } ;` ) ;
13761397 }
13771398
13781399 externalsSource . add ( content ) ;
Original file line number Diff line number Diff line change 1+ @import url (http://some/path/to/css1.css);
2+ @import url (http://some/path/to/css2.css) screen and (max-width : 1024px );
3+ @import url (http://some/path/to/css3.css) supports(dis play: grid) screen and
4+ (max-width : 400px );
5+ @import url (http://some/path/to/css4.css) supports(dis play: grid);
6+ @import url (http://some/path/to/css5.css) layer();
7+ @import url (http://some/path/to/css6.css) layer;
8+ @import url (http://some/path/to/css7.css) layer(layer- name)
9+ suppor ts(dis play: grid) screen and (max-width : 1024px );
10+ @import url (http://some/path/to/css8.css) layer(layer- name) screen and
11+ (max-width : 1024px );
12+
13+ body {
14+ background : red;
15+ }
Original file line number Diff line number Diff line change 1+ @import url ("https://some/external/css" );
2+
3+ .b {
4+ background : red;
5+ }
Original file line number Diff line number Diff line change 1+ @import url (http://some/path/to/css1.css);
2+ @import url (http://some/path/to/css2.css) screen and (max-width : 1024px );
3+ @import url (http://some/path/to/css3.css) supports(dis play: grid) screen and
4+ (max-width : 400px );
5+ @import url (http://some/path/to/css4.css) supports(dis play: grid);
6+ @import url (http://some/path/to/css5.css) layer;
7+ @import url (http://some/path/to/css6.css) layer;
8+ @import url (http://some/path/to/css7.css) layer(layer- name) suppor ts(dis play: grid) screen and (max-width : 1024px );
9+ @import url (http://some/path/to/css8.css) layer(layer- name) screen and
10+ (max-width : 1024px );
11+ @import url (https://some/external/css);
12+ body {
13+ background : red;
14+ }
15+
16+ .b {
17+ background : red;
18+ }
19+
Original file line number Diff line number Diff line change 1+ import "./a.css" ;
2+ import "./b.css" ;
Original file line number Diff line number Diff line change 1+ import Self from "../../../src" ;
2+
3+ module . exports = {
4+ entry : "./index.js" ,
5+ module : {
6+ rules : [
7+ {
8+ test : / \. c s s $ / ,
9+ use : [ Self . loader , "css-loader" ] ,
10+ } ,
11+ ] ,
12+ } ,
13+ plugins : [
14+ new Self ( {
15+ filename : "[name].css" ,
16+ } ) ,
17+ ] ,
18+ } ;
You can’t perform that action at this time.
0 commit comments