@@ -152,6 +152,18 @@ function isString(a) {
152
152
return typeof a === "string" ;
153
153
}
154
154
155
+ function isObject ( a ) {
156
+ return isType ( 'Object' , a ) ;
157
+ }
158
+
159
+ function isFunction ( a ) {
160
+ return isType ( 'Function' , a ) ;
161
+ }
162
+
163
+ function isType ( type , obj ) {
164
+ return Object . prototype . toString . call ( obj ) === '[object ' + type + ']' ;
165
+ }
166
+
155
167
ExtractTextPlugin . loader = function ( options ) {
156
168
return { loader : require . resolve ( "./loader" ) , options : options } ;
157
169
} ;
@@ -317,12 +329,23 @@ ExtractTextPlugin.prototype.apply = function(compiler) {
317
329
} ) ;
318
330
var chunk = extractedChunk . originalChunk ;
319
331
var source = this . renderExtractedChunk ( extractedChunk ) ;
320
- var file = compilation . getPath ( filename , {
332
+
333
+ var format = filename ;
334
+
335
+ if ( isObject ( filename ) ) {
336
+ format = filename . format ;
337
+ }
338
+
339
+ var file = compilation . getPath ( format , {
321
340
chunk : chunk
322
341
} ) . replace ( / \[ (?: ( \w + ) : ) ? c o n t e n t h a s h (?: : ( [ a - z ] + \d * ) ) ? (?: : ( \d + ) ) ? \] / ig, function ( ) {
323
342
return loaderUtils . getHashDigest ( source . source ( ) , arguments [ 1 ] , arguments [ 2 ] , parseInt ( arguments [ 3 ] , 10 ) ) ;
324
343
} ) ;
325
- file = ( options . filenamefilter ) ? options . filenamefilter ( file ) : file ;
344
+
345
+ if ( isFunction ( filename . modify ) ) {
346
+ file = filename . modify ( file ) ;
347
+ }
348
+
326
349
compilation . assets [ file ] = source ;
327
350
chunk . files . push ( file ) ;
328
351
}
0 commit comments