Inital commit
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
|
||||
require('ts-node/register');
|
||||
|
||||
const webpack = require('webpack');
|
||||
const config = require('../webpack.config.ts');
|
||||
|
||||
webpack(config, (error, stats) => {
|
||||
if (error) {
|
||||
console.error(error.stack || error);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(stats.toString({
|
||||
colors: true,
|
||||
chunks: false,
|
||||
modules: false
|
||||
}));
|
||||
|
||||
// Webpack 4 and some of its legacy plugins retain handles on Node.js 22.
|
||||
// The callback means all assets have been written, so terminate explicitly.
|
||||
process.exit(stats.hasErrors() ? 1 : 0);
|
||||
});
|
||||
@@ -0,0 +1,22 @@
|
||||
const loaderUtils = require('loader-utils');
|
||||
|
||||
function trim(text, g) {
|
||||
return text.substring(1, text.length - (g ? 2 : 0));
|
||||
}
|
||||
|
||||
module.exports = function(src) {
|
||||
this.cacheable();
|
||||
const options = loaderUtils.getOptions(this);
|
||||
const search = options.search;
|
||||
const g = search[search.length - 1] == 'g';
|
||||
const file = this.resourcePath.replace(/\\/g, '/');
|
||||
const replace = options.i18n ? global[options.replace].bind(null, {
|
||||
src: file,
|
||||
lang: options.lang
|
||||
}) : 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), g ? 'g' : ''), replace);
|
||||
this.callback(null, src);
|
||||
return src;
|
||||
};
|
||||
Reference in New Issue
Block a user