webpack 升级问题 webpack.NamedModulesPlugin is not a constructor
用最新版本 webpack 时出错:webpack.NamedModulesPlugin is not a constructor
提示用 use config.optimization.namedModules 替换 ‘NamedModulesPlugin’ is deprecated
这是我的配置文件
webpack.config.js
const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const webpack = require('webpack');
module.exports = {
entry: {
app: "./src/index.js"
},
devtool: "inline-source-map",
devServer: {
contentBase: "./dist",
hot: true
},
plugins: [
new CleanWebpackPlugin(),
new HtmlWebpackPlugin({
title: "webpack 入门实战",
}),
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin()
],
output: {
filename: "[name].bundle.js",
path: path.resolve(__dirname, "dist"),
publicPath: '/'
},
};
改成用配置的方式即可
optimization: {
namedModules: true
},
查看文档发布 optimization.namedModules removed (NamedModulesPlugin too) 已经被移除了。
https://app.releasly.co/releases/webpack/webpack/5_0_0-beta_0
https://stackoverflow.com/questions/49017682/webpack-4-migration-commonschunkplugin
同时在 webpack4 上是默认设置,所以不需要设置这个选项即可。
还没有评论,来说两句吧...