@@ -10,6 +10,7 @@ import SingleEntryPlugin from 'webpack/lib/SingleEntryPlugin';
10
10
import LimitChunkCountPlugin from 'webpack/lib/optimize/LimitChunkCountPlugin' ;
11
11
12
12
const NS = path . dirname ( fs . realpathSync ( __filename ) ) ;
13
+ const pluginName = 'mini-css-extract-plugin' ;
13
14
14
15
const exec = ( loaderContext , code , filename ) => {
15
16
const module = new NativeModule ( filename , loaderContext ) ;
@@ -42,25 +43,23 @@ export function pitch(request) {
42
43
publicPath,
43
44
} ;
44
45
const childCompiler = this . _compilation . createChildCompiler (
45
- `mini-css-extract-plugin ${ request } ` ,
46
+ `${ pluginName } ${ request } ` ,
46
47
outputOptions
47
48
) ;
48
49
new NodeTemplatePlugin ( outputOptions ) . apply ( childCompiler ) ;
49
50
new LibraryTemplatePlugin ( null , 'commonjs2' ) . apply ( childCompiler ) ;
50
51
new NodeTargetPlugin ( ) . apply ( childCompiler ) ;
51
- new SingleEntryPlugin (
52
- this . context ,
53
- `!!${ request } ` ,
54
- 'mini-css-extract-plugin'
55
- ) . apply ( childCompiler ) ;
52
+ new SingleEntryPlugin ( this . context , `!!${ request } ` , pluginName ) . apply (
53
+ childCompiler
54
+ ) ;
56
55
new LimitChunkCountPlugin ( { maxChunks : 1 } ) . apply ( childCompiler ) ;
57
56
// We set loaderContext[NS] = false to indicate we already in
58
57
// a child compiler so we don't spawn another child compilers from there.
59
58
childCompiler . hooks . thisCompilation . tap (
60
- 'mini-css-extract-plugin loader' ,
59
+ ` ${ pluginName } loader` ,
61
60
( compilation ) => {
62
61
compilation . hooks . normalModuleLoader . tap (
63
- 'mini-css-extract-plugin loader' ,
62
+ ` ${ pluginName } loader` ,
64
63
( loaderContext , module ) => {
65
64
loaderContext [ NS ] = false ; // eslint-disable-line no-param-reassign
66
65
if ( module . request === request ) {
@@ -79,21 +78,18 @@ export function pitch(request) {
79
78
) ;
80
79
81
80
let source ;
82
- childCompiler . hooks . afterCompile . tap (
83
- 'mini-css-extract-plugin' ,
84
- ( compilation ) => {
85
- source =
86
- compilation . assets [ childFilename ] &&
87
- compilation . assets [ childFilename ] . source ( ) ;
81
+ childCompiler . hooks . afterCompile . tap ( pluginName , ( compilation ) => {
82
+ source =
83
+ compilation . assets [ childFilename ] &&
84
+ compilation . assets [ childFilename ] . source ( ) ;
88
85
89
- // Remove all chunk assets
90
- compilation . chunks . forEach ( ( chunk ) => {
91
- chunk . files . forEach ( ( file ) => {
92
- delete compilation . assets [ file ] ; // eslint-disable-line no-param-reassign
93
- } ) ;
86
+ // Remove all chunk assets
87
+ compilation . chunks . forEach ( ( chunk ) => {
88
+ chunk . files . forEach ( ( file ) => {
89
+ delete compilation . assets [ file ] ; // eslint-disable-line no-param-reassign
94
90
} ) ;
95
- }
96
- ) ;
91
+ } ) ;
92
+ } ) ;
97
93
98
94
const callback = this . async ( ) ;
99
95
childCompiler . runAsChild ( ( err , entries , compilation ) => {
@@ -133,7 +129,7 @@ export function pitch(request) {
133
129
} catch ( e ) {
134
130
return callback ( e ) ;
135
131
}
136
- let resultSource = ' // extracted by mini-css-extract-plugin' ;
132
+ let resultSource = ` // extracted by ${ pluginName } ` ;
137
133
if ( locals && typeof resultSource !== 'undefined' ) {
138
134
resultSource += `\nmodule.exports = ${ JSON . stringify ( locals ) } ;` ;
139
135
}
0 commit comments