@@ -188,15 +188,15 @@ ExtractTextPlugin.prototype.loader = function(options) {
188
188
ExtractTextPlugin . prototype . extract = function ( options ) {
189
189
if ( arguments . length > 1 ) {
190
190
throw new Error ( "Breaking change: extract now only takes a single argument. Either an options " +
191
- "object *or* the loader(s).\n" +
192
- "Example: if your old code looked like this:\n" +
193
- " ExtractTextPlugin.extract('style-loader', 'css-loader')\n\n" +
194
- "You would change it to:\n" +
195
- " ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' })\n\n" +
196
- "The available options are:\n" +
197
- " use: string | object | loader[]\n" +
198
- " fallback: string | object | loader[]\n" +
199
- " publicPath: string\n" ) ;
191
+ "object *or* the loader(s).\n" +
192
+ "Example: if your old code looked like this:\n" +
193
+ " ExtractTextPlugin.extract('style-loader', 'css-loader')\n\n" +
194
+ "You would change it to:\n" +
195
+ " ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' })\n\n" +
196
+ "The available options are:\n" +
197
+ " use: string | object | loader[]\n" +
198
+ " fallback: string | object | loader[]\n" +
199
+ " publicPath: string\n" ) ;
200
200
}
201
201
if ( options . fallbackLoader ) {
202
202
console . warn ( 'fallbackLoader option has been deprecated - replace with "fallback"' ) ;
@@ -227,7 +227,7 @@ ExtractTextPlugin.prototype.extract = function(options) {
227
227
return [ this . loader ( options ) ]
228
228
. concat ( before , loader )
229
229
. map ( getLoaderObject ) ;
230
- }
230
+ } ;
231
231
232
232
ExtractTextPlugin . extract = ExtractTextPlugin . prototype . extract . bind ( ExtractTextPlugin ) ;
233
233
@@ -340,12 +340,14 @@ ExtractTextPlugin.prototype.apply = function(compiler) {
340
340
module . request ,
341
341
module . userRequest ,
342
342
module . rawRequest ,
343
- [ ] ,
343
+ module . loaders ,
344
344
module . resource ,
345
345
module . parser
346
346
) ;
347
347
newModule . id = id ;
348
- newModule . _source = new OriginalSource ( '// removed by extract-text-webpack-plugin' ) ;
348
+ var localsMatch = module . _source . _value . match ( / e x p o r t s \. l o c a l s ( [ \s \S ] * } ; ) / ) ;
349
+ localsMatch = localsMatch ? 'module.exports = ' + localsMatch [ 0 ] : null ;
350
+ newModule . _source = new OriginalSource ( '// removed by extract-text-webpack-plugin\n' + ( localsMatch || '' ) ) ;
349
351
data . chunks . forEach ( function ( chunk ) {
350
352
chunk . removeModule ( module ) ;
351
353
chunk . addModule ( newModule ) ;
0 commit comments