@@ -10,6 +10,7 @@ import SingleEntryPlugin from 'webpack/lib/SingleEntryPlugin';
1010import LimitChunkCountPlugin from 'webpack/lib/optimize/LimitChunkCountPlugin' ;
1111
1212const NS = path . dirname ( fs . realpathSync ( __filename ) ) ;
13+ const pluginName = 'mini-css-extract-plugin' ;
1314
1415const exec = ( loaderContext , code , filename ) => {
1516 const module = new NativeModule ( filename , loaderContext ) ;
@@ -42,25 +43,23 @@ export function pitch(request) {
4243 publicPath,
4344 } ;
4445 const childCompiler = this . _compilation . createChildCompiler (
45- `mini-css-extract-plugin ${ request } ` ,
46+ `${ pluginName } ${ request } ` ,
4647 outputOptions
4748 ) ;
4849 new NodeTemplatePlugin ( outputOptions ) . apply ( childCompiler ) ;
4950 new LibraryTemplatePlugin ( null , 'commonjs2' ) . apply ( childCompiler ) ;
5051 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+ ) ;
5655 new LimitChunkCountPlugin ( { maxChunks : 1 } ) . apply ( childCompiler ) ;
5756 // We set loaderContext[NS] = false to indicate we already in
5857 // a child compiler so we don't spawn another child compilers from there.
5958 childCompiler . hooks . thisCompilation . tap (
60- 'mini-css-extract-plugin loader' ,
59+ ` ${ pluginName } loader` ,
6160 ( compilation ) => {
6261 compilation . hooks . normalModuleLoader . tap (
63- 'mini-css-extract-plugin loader' ,
62+ ` ${ pluginName } loader` ,
6463 ( loaderContext , module ) => {
6564 loaderContext [ NS ] = false ; // eslint-disable-line no-param-reassign
6665 if ( module . request === request ) {
@@ -79,21 +78,18 @@ export function pitch(request) {
7978 ) ;
8079
8180 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 ( ) ;
8885
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
9490 } ) ;
95- }
96- ) ;
91+ } ) ;
92+ } ) ;
9793
9894 const callback = this . async ( ) ;
9995 childCompiler . runAsChild ( ( err , entries , compilation ) => {
@@ -133,7 +129,7 @@ export function pitch(request) {
133129 } catch ( e ) {
134130 return callback ( e ) ;
135131 }
136- let resultSource = ' // extracted by mini-css-extract-plugin' ;
132+ let resultSource = ` // extracted by ${ pluginName } ` ;
137133 if ( locals && typeof resultSource !== 'undefined' ) {
138134 resultSource += `\nmodule.exports = ${ JSON . stringify ( locals ) } ;` ;
139135 }
0 commit comments