Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 12d167c

Browse files
codechaoticjoshwiens
authored andcommitted
feat: Permit {path} and {query} in asset name
1 parent e6f493d commit 12d167c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

index.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
Author Tobias Koppers @sokra
44
*/
55
var async = require("async");
6+
var url = require('url');
67

78
var RawSource = require("webpack/lib/RawSource");
89

@@ -36,7 +37,15 @@ CompressionPlugin.prototype.apply = function(compiler) {
3637
this.algorithm(content, function(err, result) {
3738
if(err) return callback(err);
3839
if(result.length / originalSize > this.minRatio) return callback();
39-
var newFile = this.asset.replace(/\{file\}/g, file);
40+
var parse = url.parse(file);
41+
var sub = {
42+
file: file,
43+
path: parse.pathname,
44+
query: parse.query
45+
}
46+
var newFile = this.asset.replace(/\{(file|path|query)\}/g, function(p0,p1) {
47+
return sub[p1];
48+
});
4049
assets[newFile] = new RawSource(result);
4150
callback();
4251
}.bind(this));

0 commit comments

Comments
 (0)