Skip to content
This repository was archived by the owner on Nov 5, 2019. It is now read-only.

Commit 8010e42

Browse files
committed
Fix issue with absolute paths using loaderUtils.stringifyRequest instead of JSON.stringify
1 parent 6f423f6 commit 8010e42

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

index.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@
33
Author Tobias Koppers @sokra
44
*/
55
var path = require("path");
6+
var loaderUtils = require("loader-utils");
67
module.exports = function() {};
78
module.exports.pitch = function(remainingRequest) {
8-
this.cacheable && this.cacheable();
9-
return "require(" + JSON.stringify("!!" + path.join(__dirname, "addScript.js")) + ")"+
10-
"(require(" +
11-
JSON.stringify("!!" + require.resolve("raw-loader") + "!" + remainingRequest) + ")" +
12-
(this.debug ?
13-
"+" +
14-
JSON.stringify(
15-
"\n\n// SCRIPT-LOADER FOOTER\n//# sourceURL=script:///" +
16-
encodeURI(remainingRequest.replace(/^!/, "")).replace(/%5C|%2F/g, "/").replace(/\?/, "%3F").replace(/^\//, "")
17-
) :
18-
"") +
19-
")";
20-
};
9+
this.cacheable && this.cacheable();
10+
return "require(" + loaderUtils.stringifyRequest(this, "!!" + path.join(__dirname, "addScript.js")) + ")"+
11+
"(require(" +
12+
loaderUtils.stringifyRequest(this, "!!" + require.resolve("raw-loader") + "!" + remainingRequest) + ")" +
13+
(this.debug ?
14+
"+" +
15+
JSON.stringify(
16+
"\n\n// SCRIPT-LOADER FOOTER\n//# sourceURL=script:///" +
17+
encodeURI(remainingRequest.replace(/^!/, "")).replace(/%5C|%2F/g, "/").replace(/\?/, "%3F").replace(/^\//, "")
18+
) :
19+
"") +
20+
")";
21+
};

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"release": "standard-version"
99
},
1010
"dependencies": {
11-
"raw-loader": "~0.5.1"
11+
"raw-loader": "~0.5.1",
12+
"loader-utils": "~1.1.0"
1213
},
1314
"devDependencies": {
1415
"standard-version": "^4.2.0"

0 commit comments

Comments
 (0)