@@ -152,6 +152,18 @@ function isString(a) {
152152 return typeof a === "string" ;
153153}
154154
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+
155167ExtractTextPlugin . loader = function ( options ) {
156168 return { loader : require . resolve ( "./loader" ) , options : options } ;
157169} ;
@@ -317,12 +329,23 @@ ExtractTextPlugin.prototype.apply = function(compiler) {
317329 } ) ;
318330 var chunk = extractedChunk . originalChunk ;
319331 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 , {
321340 chunk : chunk
322341 } ) . replace ( / \[ (?: ( \w + ) : ) ? c o n t e n t h a s h (?: : ( [ a - z ] + \d * ) ) ? (?: : ( \d + ) ) ? \] / ig, function ( ) {
323342 return loaderUtils . getHashDigest ( source . source ( ) , arguments [ 1 ] , arguments [ 2 ] , parseInt ( arguments [ 3 ] , 10 ) ) ;
324343 } ) ;
325- file = ( options . filenamefilter ) ? options . filenamefilter ( file ) : file ;
344+
345+ if ( isFunction ( filename . modify ) ) {
346+ file = filename . modify ( file ) ;
347+ }
348+
326349 compilation . assets [ file ] = source ;
327350 chunk . files . push ( file ) ;
328351 }
0 commit comments