我尝试webpack一个node.js模块并遇到一些代码,我们尝试require
JSON
一个var tryRequire = function(filename){
var result = null;
if (fs.existsSync(filename)){
result = require(filename);
}
return result;
}
var getI18nStorage = function(culture){
var cultureParts = culture.toLowerCase().split("-");
var dir = path.join(__dirname, "../../i18n/address");
var fn = cultureParts[0] + ".json";
var filename = path.join(dir, fn);
var storage = tryRequire(filename);
if (!storage){
fn = cultureParts[1] + ".json";
filename = path.join(dir, fn);
storage = tryRequire(filename);
if (!storage){
fn = "us.json";
filename = path.join(dir, fn);
storage = tryRequire(filename);
/* if (!storage){
console.log(culture, "nothing found");
process.exit(1)
}*/
}
}
return storage;
}
文件,并回退到所有事件中都存在的文件。以下代码是webpack的难题。
var c = getI18nStorage("en-GB");
目前打包!(function webpackMissingModule() { var e = new Error("Cannot find module \".\""); e.code = 'MODULE_NOT_FOUND'; throw e;
会产生context: path.join(__dirname, "../lib/i18n"),
,这是可以理解的:o)
我试图向https://github.com/webpack/webpack/tree/master/examples/require.context学习,但无法将技术转移到我的问题上。我想我需要知道两件事:
ps.setInt(1,id);//set param
ResultSet rs= ps.executeQuery();//then execute your statement
添加到webpack配置中,但这不包括捆绑输出的数据。