wip
This commit is contained in:
parent
a7601f7aa4
commit
085ac938c2
@ -125,6 +125,7 @@
|
|||||||
"is-url": "1.2.2",
|
"is-url": "1.2.2",
|
||||||
"js-yaml": "3.10.0",
|
"js-yaml": "3.10.0",
|
||||||
"license-checker": "16.0.0",
|
"license-checker": "16.0.0",
|
||||||
|
"loader-utils": "^1.1.0",
|
||||||
"mecab-async": "0.1.2",
|
"mecab-async": "0.1.2",
|
||||||
"mkdirp": "0.5.1",
|
"mkdirp": "0.5.1",
|
||||||
"mocha": "5.0.0",
|
"mocha": "5.0.0",
|
||||||
|
15
webpack/loaders/replace.js
Normal file
15
webpack/loaders/replace.js
Normal 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;
|
||||||
|
};
|
@ -5,12 +5,12 @@
|
|||||||
import { pattern, replacement } from '../../../src/common/build/fa';
|
import { pattern, replacement } from '../../../src/common/build/fa';
|
||||||
|
|
||||||
export default () => ({
|
export default () => ({
|
||||||
enforce: 'pre',
|
//enforce: 'pre',
|
||||||
test: /\.(vue|js|ts)$/,
|
test: /\.(vue|js|ts)$/,
|
||||||
exclude: /node_modules/,
|
exclude: /node_modules/,
|
||||||
loader: 'string-replace-loader',
|
loader: 'replace',
|
||||||
query: {
|
query: {
|
||||||
search: pattern,
|
search: pattern.toString(),
|
||||||
replace: replacement
|
replace: replacement
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -8,12 +8,12 @@ export default lang => {
|
|||||||
const replacer = new Replacer(lang);
|
const replacer = new Replacer(lang);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
enforce: 'pre',
|
//enforce: 'post',
|
||||||
test: /\.(vue|js|ts)$/,
|
test: /\.(vue|js|ts)$/,
|
||||||
exclude: /node_modules/,
|
exclude: /node_modules/,
|
||||||
loader: 'string-replace-loader',
|
loader: 'replace',
|
||||||
query: {
|
query: {
|
||||||
search: replacer.pattern,
|
search: replacer.pattern.toString(),
|
||||||
replace: replacer.replacement
|
replace: replacer.replacement
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -8,10 +8,11 @@ import collapseSpaces from './collapse-spaces';
|
|||||||
|
|
||||||
export default lang => [
|
export default lang => [
|
||||||
//collapseSpaces(),
|
//collapseSpaces(),
|
||||||
//i18n(lang),
|
|
||||||
//fa(),
|
|
||||||
//base64(),
|
//base64(),
|
||||||
vue(),
|
vue(),
|
||||||
|
i18n(lang),
|
||||||
|
fa(),
|
||||||
stylus(),
|
stylus(),
|
||||||
typescript()
|
typescript()
|
||||||
];
|
];
|
||||||
|
@ -40,6 +40,9 @@ module.exports = Object.keys(langs).map(lang => {
|
|||||||
'.js', '.ts'
|
'.js', '.ts'
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
resolveLoader: {
|
||||||
|
modules: ['node_modules', './webpack/loaders']
|
||||||
|
},
|
||||||
cache: true,
|
cache: true,
|
||||||
devtool: 'eval',
|
devtool: 'eval',
|
||||||
stats: true,
|
stats: true,
|
||||||
|
Loading…
Reference in New Issue
Block a user