This commit is contained in:
syuilo 2018-02-16 02:53:54 +09:00
parent a7601f7aa4
commit 085ac938c2
6 changed files with 28 additions and 8 deletions

View file

@ -125,6 +125,7 @@
"is-url": "1.2.2",
"js-yaml": "3.10.0",
"license-checker": "16.0.0",
"loader-utils": "^1.1.0",
"mecab-async": "0.1.2",
"mkdirp": "0.5.1",
"mocha": "5.0.0",

View file

@ -0,0 +1,15 @@
const loaderUtils = require('loader-utils');
function trim(text) {
return text.substring(1, text.length - 2);
}
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);
this.callback(null, src);
return src;
};

View file

@ -5,12 +5,12 @@
import { pattern, replacement } from '../../../src/common/build/fa';
export default () => ({
enforce: 'pre',
//enforce: 'pre',
test: /\.(vue|js|ts)$/,
exclude: /node_modules/,
loader: 'string-replace-loader',
loader: 'replace',
query: {
search: pattern,
search: pattern.toString(),
replace: replacement
}
});

View file

@ -8,12 +8,12 @@ export default lang => {
const replacer = new Replacer(lang);
return {
enforce: 'pre',
//enforce: 'post',
test: /\.(vue|js|ts)$/,
exclude: /node_modules/,
loader: 'string-replace-loader',
loader: 'replace',
query: {
search: replacer.pattern,
search: replacer.pattern.toString(),
replace: replacer.replacement
}
};

View file

@ -8,10 +8,11 @@ import collapseSpaces from './collapse-spaces';
export default lang => [
//collapseSpaces(),
//i18n(lang),
//fa(),
//base64(),
vue(),
i18n(lang),
fa(),
stylus(),
typescript()
];

View file

@ -40,6 +40,9 @@ module.exports = Object.keys(langs).map(lang => {
'.js', '.ts'
]
},
resolveLoader: {
modules: ['node_modules', './webpack/loaders']
},
cache: true,
devtool: 'eval',
stats: true,