@@ -18,7 +18,7 @@ class CssDependency extends webpack.Dependency {
1818 }
1919
2020 getResourceIdentifier ( ) {
21- return `cssmodule ${ this . identifier } ` ;
21+ return `css-module- ${ this . identifier } ` ;
2222 }
2323}
2424
@@ -45,14 +45,14 @@ class CssModule extends webpack.Module {
4545 }
4646
4747 identifier ( ) {
48- return `css-module ${ this . _identifier } ` ;
48+ return `css ${ this . _identifier } ` ;
4949 }
5050
5151 readableIdentifier ( requestShortener ) {
52- return `css-modules ${ requestShortener . shorten ( this . _identifier ) } ` ;
52+ return `css ${ requestShortener . shorten ( this . _identifier ) } ` ;
5353 }
5454
55- build ( options , compilation , resolver , fs , callback ) {
55+ build ( options , compilation , resolver , fileSystem , callback ) {
5656 this . buildInfo = { } ;
5757 this . buildMeta = { } ;
5858 callback ( ) ;
@@ -101,7 +101,20 @@ class MiniCssExtractPlugin {
101101 pathOptions : {
102102 chunk,
103103 } ,
104- identifier : `extract-text-webpack-plugin.${ chunk . id } ` ,
104+ identifier : `mini-css-extract-plugin.${ chunk . id } ` ,
105+ } ) ;
106+ }
107+ } ) ;
108+ compilation . chunkTemplate . hooks . renderManifest . tap ( 'mini-css-extract-plugin' , ( result , { chunk } ) => {
109+ const renderedModules = Array . from ( chunk . modulesIterable ) . filter ( module => module . type === NS ) ;
110+ if ( renderedModules . length > 0 ) {
111+ result . push ( {
112+ render : ( ) => this . renderContentAsset ( renderedModules ) ,
113+ filenameTemplate : this . options . chunkFilename ,
114+ pathOptions : {
115+ chunk,
116+ } ,
117+ identifier : `mini-css-extract-plugin.${ chunk . id } ` ,
105118 } ) ;
106119 }
107120 } ) ;
@@ -112,13 +125,14 @@ class MiniCssExtractPlugin {
112125 // TODO put @import on top
113126 const source = new ConcatSource ( ) ;
114127 for ( const m of modules ) {
128+ if ( m . media ) {
129+ source . add ( `@media ${ m . media } {\n` ) ;
130+ }
115131 source . add ( m . content ) ;
116132 source . add ( '\n' ) ;
117133 if ( m . media ) {
118- source . prepend ( `@media ${ m . media } {\n` ) ;
119134 source . add ( '}\n' ) ;
120135 }
121- return source ;
122136 }
123137 return source ;
124138 }
0 commit comments