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

Commit d090194

Browse files
committed
use loader utils
1 parent 615546c commit d090194

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

index.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@
33
Author Tobias Koppers @sokra
44
*/
55
var path = require("path");
6+
var loaderUtils = require("loader-utils");
67
module.exports = function(content) {
78
this.cacheable && this.cacheable();
89
this.clearDependencies && this.clearDependencies();
9-
var loaderSign = this.request.indexOf("!");
10-
var rawJs = this.request.substr(loaderSign); // including leading "!"
11-
if(this.web)
12-
return "require(" + JSON.stringify(path.join(__dirname, "addScript")) + ")"+
13-
"(require(" +
14-
JSON.stringify("raw" + rawJs) + "))";
15-
return "";
10+
var rawJs = loaderUtils.getRemainingRequest(this);
11+
return "require(" + JSON.stringify(path.join(__dirname, "addScript" + (this.web ? ".web" : "") + ".js")) + ")"+
12+
"(require(" +
13+
JSON.stringify("raw" + rawJs) + "))";
1614
}
1715
module.exports.seperable = true;

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{
22
"name": "script-loader",
3-
"version": "0.2.0",
3+
"version": "0.3.0",
44
"author": "Tobias Koppers @sokra",
55
"description": "script loader module for webpack",
66
"dependencies": {
7-
"raw-loader": "0.1.x"
7+
"raw-loader": "0.1.x",
8+
"loader-utils": "0.1.x"
89
},
910
"licenses": [
1011
{

0 commit comments

Comments
 (0)