summaryrefslogtreecommitdiff
path: root/webpack/loaders/replace.js
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2018-02-16 03:23:10 +0900
committersyuilo <syuilotan@yahoo.co.jp>2018-02-16 03:23:10 +0900
commit11f32375b662c7584aeb0efae4513ea07e8bb1b3 (patch)
tree247b540f5c66daebc05885ea46d8a8bbca1b812c /webpack/loaders/replace.js
parentwip (diff)
downloadmisskey-11f32375b662c7584aeb0efae4513ea07e8bb1b3.tar.gz
misskey-11f32375b662c7584aeb0efae4513ea07e8bb1b3.tar.bz2
misskey-11f32375b662c7584aeb0efae4513ea07e8bb1b3.zip
wip
Diffstat (limited to 'webpack/loaders/replace.js')
-rw-r--r--webpack/loaders/replace.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/webpack/loaders/replace.js b/webpack/loaders/replace.js
index 41c33ce8d6..4bb00a2abf 100644
--- a/webpack/loaders/replace.js
+++ b/webpack/loaders/replace.js
@@ -7,9 +7,11 @@ function trim(text) {
module.exports = function(src) {
this.cacheable();
const options = loaderUtils.getOptions(this);
- if (typeof options.search != 'string' || options.search.length == 0) console.error('invalid search');
- if (typeof options.replace != 'function') console.error('invalid replacer');
- src = src.replace(new RegExp(trim(options.search), 'g'), options.replace);
+ const search = options.search;
+ const replace = global[options.replace];
+ 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'), replace);
this.callback(null, src);
return src;
};