-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
22 lines (17 loc) · 623 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var loaderUtils = require('loader-utils');
module.exports = function (content) {
this.cacheable && this.cacheable();
var query = loaderUtils.getOptions(this);
var config = Object.assign({}, defaults, query);
var singleLinePattern = `\\/\\/\\s*${config.match}\\s*(.*?)\\s*`;
var multiLinePattern = `\\/\\*\\s*${config.match}\\s*([\\s\\S]*?)\\s*\\*\\/`;
if (config.enable) {
content = content.replace(new RegExp(singleLinePattern, 'gi'), '$1');
content = content.replace(new RegExp(multiLinePattern, 'gim'), '$1');
}
return content;
};
var defaults = {
match: '@[\\w-]+@',
enable: true
};