This commit is contained in:
syuilo 2018-05-17 19:38:20 +09:00
parent 7ab8b30b46
commit 439d3659e4
3 changed files with 33 additions and 32 deletions

View file

@ -209,7 +209,7 @@
"vue-cropperjs": "2.2.0", "vue-cropperjs": "2.2.0",
"vue-js-modal": "1.3.13", "vue-js-modal": "1.3.13",
"vue-json-tree-view": "2.1.4", "vue-json-tree-view": "2.1.4",
"vue-loader": "15.0.5", "vue-loader": "15.0.11",
"vue-router": "3.0.1", "vue-router": "3.0.1",
"vue-template-compiler": "2.5.16", "vue-template-compiler": "2.5.16",
"vuedraggable": "2.16.0", "vuedraggable": "2.16.0",

View file

@ -146,27 +146,20 @@ module.exports = {
}, { }, {
loader: 'replace', loader: 'replace',
query: { query: {
qs: [{
search: /%base64:(.+?)%/g.toString(), search: /%base64:(.+?)%/g.toString(),
replace: 'base64replacement' replace: 'base64replacement'
}
}, { }, {
loader: 'replace',
query: {
search: i18nPattern.toString(), search: i18nPattern.toString(),
replace: 'i18nReplacement', replace: 'i18nReplacement',
i18n: true i18n: true
}
}, { }, {
loader: 'replace',
query: {
search: faPattern.toString(), search: faPattern.toString(),
replace: 'faReplacement' replace: 'faReplacement'
}
}, { }, {
loader: 'replace',
query: {
search: /^<template>([\s\S]+?)\r?\n<\/template>/.toString(), search: /^<template>([\s\S]+?)\r?\n<\/template>/.toString(),
replace: 'collapseSpacesReplacement' replace: 'collapseSpacesReplacement'
}]
} }
}] }]
}, { }, {

View file

@ -5,8 +5,7 @@ function trim(text, g) {
} }
export default function(src) { export default function(src) {
this.cacheable(); const fn = options => {
const options = getOptions(this);
const search = options.search; const search = options.search;
const g = search[search.length - 1] == 'g'; const g = search[search.length - 1] == 'g';
const file = this.resourcePath.replace(/\\/g, '/'); const file = this.resourcePath.replace(/\\/g, '/');
@ -17,6 +16,15 @@ export default function(src) {
if (typeof search != 'string' || search.length == 0) console.error('invalid search'); if (typeof search != 'string' || search.length == 0) console.error('invalid search');
if (typeof replace != 'function') console.error('invalid replacer:', replace, this.request); if (typeof replace != 'function') console.error('invalid replacer:', replace, this.request);
src = src.replace(new RegExp(trim(search, g), g ? 'g' : ''), replace); src = src.replace(new RegExp(trim(search, g), g ? 'g' : ''), replace);
};
this.cacheable();
const options = getOptions(this);
if (options.qs) {
options.qs.forEach(q => fn(q));
} else {
fn(options);
}
this.callback(null, src); this.callback(null, src);
return src; return src;
} }