我正在使用webpack 4将脚本打包到我的Asp.net Mvc项目中,该项目在本地运行良好,但是在生产环境中,我收到“ webpack_require 未定义”错误。这行' webpack_require .r( webpack_exports );'在生产中的app.js中似乎是问题的根源。似乎是出现此问题的“应用”脚本条目。
这是我的webpack.config.js
const path = require("path");
const TerserPlugin = require("terser-webpack-plugin");
module.exports = {
entry: {
errorLog: "./Content/Scripts/MyApp/Logs/ErrorLog/index.js",
user: "./Content/Scripts/MyApp/User/index.js",
app: "./Content/Scripts/MyApp/app.js",
},
output: {
path: path.resolve(__dirname, "./Content/Scripts/build"),
filename: "[name].bundle.min.js"
},
module: {
rules: [
{
loader: "babel-loader",
test: "/\.js$/",
exclude: "/node_modules"
}
]
},
plugins: [
new TerserPlugin({
parallel: true,
terserOptions: {
ecma: 6
}
})
]
}