webpack.config.js配置文件报错:The 'mode' option has not been set
WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for th
is value. Set 'mode' option to 'development' or 'production' to enable defaults
for each environment.
You can also set it to 'none' to disable any default behavior. Learn more: https
://webpack.js.org/concepts/mode/
在cmd下运行webpack命令时,提示以上错误,大概意思是:
没有设定是开发模式还是生产模式,要求指定。
解决:
1、在package.json文件里进行修改:增加如下:
"dev": "webpack --mode development",
"build": "webpack --mode production"
2、也可以在写webpack.config.js中增加一个选项:mode。mode:"development",
如:
const HtmlWebpackPlugin = require('html-webpack-plugin'); module.exports = { mode:"development", ...}
3、不能在cmd中运行webpack命令,否则还会提示,应该运行命令:npm run build
转自:https://blog.csdn.net/jiang7701037/article/details/80682662