@@ -984,35 +984,36 @@ class MiniCssExtractPlugin {
984
984
compiler . webpack . sources ;
985
985
const source = new ConcatSource ( ) ;
986
986
const externalsSource = new ConcatSource ( ) ;
987
- const includePathinfo = compilation . outputOptions . pathinfo ;
988
987
989
- for ( const m of usedModules ) {
990
- let content = m . content . toString ( ) ;
988
+ for ( const module of usedModules ) {
989
+ let content = module . content . toString ( ) ;
991
990
992
- if ( includePathinfo ) {
991
+ const readableIdentifier = module . readableIdentifier ( requestShortener ) ;
992
+
993
+ if ( compilation . outputOptions . pathinfo ) {
993
994
// From https://github.com/webpack/webpack/blob/29eff8a74ecc2f87517b627dee451c2af9ed3f3f/lib/ModuleInfoHeaderPlugin.js#L191-L194
994
- const req = m . readableIdentifier ( requestShortener ) ;
995
- const reqStr = req . replace ( / \* \/ / g, "*_/" ) ;
995
+ const reqStr = readableIdentifier . replace ( / \* \/ / g, "*_/" ) ;
996
996
const reqStrStar = "*" . repeat ( reqStr . length ) ;
997
997
const headerStr = `/*!****${ reqStrStar } ****!*\\\n !*** ${ reqStr } ***!\n \\****${ reqStrStar } ****/\n` ;
998
+
998
999
content = headerStr + content ;
999
1000
}
1000
1001
1001
1002
if ( / ^ @ i m p o r t u r l / . test ( content ) ) {
1002
1003
// HACK for IE
1003
1004
// http://stackoverflow.com/a/14676665/1458162
1004
- if ( m . media ) {
1005
+ if ( module . media ) {
1005
1006
// insert media into the @import
1006
1007
// this is rar
1007
1008
// TODO improve this and parse the CSS to support multiple medias
1008
- content = content . replace ( / ; | \s * $ / , m . media ) ;
1009
+ content = content . replace ( / ; | \s * $ / , module . media ) ;
1009
1010
}
1010
1011
1011
1012
externalsSource . add ( content ) ;
1012
1013
externalsSource . add ( "\n" ) ;
1013
1014
} else {
1014
- if ( m . media ) {
1015
- source . add ( `@media ${ m . media } {\n` ) ;
1015
+ if ( module . media ) {
1016
+ source . add ( `@media ${ module . media } {\n` ) ;
1016
1017
}
1017
1018
1018
1019
const { path : filename } = compilation . getPathWithInfo (
@@ -1024,22 +1025,21 @@ class MiniCssExtractPlugin {
1024
1025
1025
1026
content = content . replace ( new RegExp ( AUTO_PUBLIC_PATH , "g" ) , undoPath ) ;
1026
1027
1027
- if ( m . sourceMap ) {
1028
+ if ( module . sourceMap ) {
1028
1029
source . add (
1029
1030
new SourceMapSource (
1030
1031
content ,
1031
- m . readableIdentifier ( requestShortener ) ,
1032
- m . sourceMap . toString ( )
1032
+ readableIdentifier ,
1033
+ module . sourceMap . toString ( )
1033
1034
)
1034
1035
) ;
1035
1036
} else {
1036
- source . add (
1037
- new RawSource ( content , m . readableIdentifier ( requestShortener ) )
1038
- ) ;
1037
+ source . add ( new RawSource ( content , readableIdentifier ) ) ;
1039
1038
}
1039
+
1040
1040
source . add ( "\n" ) ;
1041
1041
1042
- if ( m . media ) {
1042
+ if ( module . media ) {
1043
1043
source . add ( "}\n" ) ;
1044
1044
}
1045
1045
}
0 commit comments