From 8d75f0e523225bb021dd6e06796e2fd6a27b19dd Mon Sep 17 00:00:00 2001 From: codechaotic Date: Wed, 12 Aug 2015 16:44:15 -0400 Subject: [PATCH 1/2] Permit {path} and {query} in asset name --- index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 8806fb2..16d86dc 100644 --- a/index.js +++ b/index.js @@ -3,6 +3,7 @@ Author Tobias Koppers @sokra */ var async = require("async"); +var url = require('url'); var RawSource = require("webpack/lib/RawSource"); @@ -36,7 +37,15 @@ CompressionPlugin.prototype.apply = function(compiler) { this.algorithm(content, function(err, result) { if(err) return callback(err); if(result.length / originalSize > this.minRatio) return callback(); - var newFile = this.asset.replace(/\{file\}/g, file); + var parse = url.parse(file); + var sub = { + file: file, + path: parse.pathname, + query: parse.query + } + var newFile = this.asset.replace(/\{(file|path|query)\}/g, function(p0,p1) { + return sub[p1]; + }); assets[newFile] = new RawSource(result); callback(); }.bind(this)); From 31747c4f96ed77a245724a5f1185e569efaf6dae Mon Sep 17 00:00:00 2001 From: codechaotic Date: Wed, 12 Aug 2015 17:16:23 -0400 Subject: [PATCH 2/2] Add missing semicolon --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 16d86dc..5889cc4 100644 --- a/index.js +++ b/index.js @@ -42,7 +42,7 @@ CompressionPlugin.prototype.apply = function(compiler) { file: file, path: parse.pathname, query: parse.query - } + }; var newFile = this.asset.replace(/\{(file|path|query)\}/g, function(p0,p1) { return sub[p1]; });