嗨,我想创建一个捆绑的节点应用程序(server.js)。这已经适用于webpack配置。但是我想拥有一个配置文件(config.json),此后我仍然可以对其进行配置(我在我的server.js中使用require('./ config')进行配置)。在构建应用后,webpack如何允许它要求它。
const path = require('path');
const nodeExternals = require('webpack-node-externals');
var webpack = require('webpack');
module.exports = {
target: "node",
entry: {
app: ["./server.js"]
},
output: {
path: path.resolve(__dirname, "./dist"),
filename: "bundle.js"
},
externals: [nodeExternals()],
plugins: [
new webpack.IgnorePlugin(/config/)
]
};