From 335f9e683b91cd68d7e33c2b64cd586202fe8387 Mon Sep 17 00:00:00 2001 From: Gary Borton Date: Tue, 14 Feb 2017 10:49:58 -0800 Subject: [PATCH] fix(remainingRequest): resolve issue when multiple variables are exposed for the same request. (#30) The previous commit for more consistent hashes naively overwrote the entire request, assuming there weren't additional loaders to be run against the file. This modifies the changes to the request to only change the path to the imported file rather than changing the entire remainingRequest. --- index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index a6f0584..e5eda89 100644 --- a/index.js +++ b/index.js @@ -26,7 +26,10 @@ module.exports.pitch = function(remainingRequest) { // Change the request from an /abolute/path.js to a relative ./path.js // This prevents [chunkhash] values from changing when running webpack // builds in different directories. - var newRequestPath = "." + path.sep + path.basename(remainingRequest); + const newRequestPath = remainingRequest.replace( + this.resourcePath, + '.' + path.sep + path.relative(this.context, this.resourcePath) + ); this.cacheable && this.cacheable(); if(!this.query) throw new Error("query parameter is missing"); return accesorString(this.query.substr(1)) + " = " +