当我尝试从 webpack 4 更新到 webpack 5 时,出现错误。
这是我的新 webpack.config:
const { merge } = require('webpack-merge');
const common = require("./webpack.common.js");
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const Dotenv = require('dotenv-webpack');
module.exports = merge(common, {
mode: "development",
devtool: "inline-source-map",
watchOptions: {
poll: true,
ignored: '/node_modules/',
},
devServer: {
contentBase: path.join(__dirname, "public"),
inline: true,
compress: true,
port: 9000,
historyApiFallback: true
},
plugins: [
new HtmlWebpackPlugin({
template: path.join(__dirname, "public", "index.html"),
fileName: path.join('.', 'build', 'index.html')
}),
new Dotenv({
path: './.env', // Path to …Run Code Online (Sandbox Code Playgroud)