diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2018-04-15 01:04:40 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2018-04-15 01:04:40 +0900 |
| commit | 554570cb0964f9eca6eb3d645a0a2ca0550d4733 (patch) | |
| tree | bafc924dea123f6d08ec3c38c682957e2b519e86 /webpack/loaders | |
| parent | :v: (diff) | |
| download | sharkey-554570cb0964f9eca6eb3d645a0a2ca0550d4733.tar.gz sharkey-554570cb0964f9eca6eb3d645a0a2ca0550d4733.tar.bz2 sharkey-554570cb0964f9eca6eb3d645a0a2ca0550d4733.zip | |
wip
Diffstat (limited to 'webpack/loaders')
| -rw-r--r-- | webpack/loaders/replace.js | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/webpack/loaders/replace.js b/webpack/loaders/replace.js index 03cf1fcd78..8018e9cec2 100644 --- a/webpack/loaders/replace.js +++ b/webpack/loaders/replace.js @@ -9,7 +9,10 @@ module.exports = function(src) { const options = loaderUtils.getOptions(this); const search = options.search; const g = search[search.length - 1] == 'g'; - const replace = global[options.replace]; + const file = this.resourcePath.replace(/\\/g, '/'); + const replace = global[options.replace].bind(null, { + src: file + }); if (typeof search != 'string' || search.length == 0) console.error('invalid search'); if (typeof replace != 'function') console.error('invalid replacer:', replace, this.request); src = src.replace(new RegExp(trim(search, g), g ? 'g' : ''), replace); |