WARNING in configuration The 'mode' option has not been set, webpack will fallback to 'production' f

WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this 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/configuration/mode/

 

以上是我在第一次用webpack打包是遇到的错误,翻了好多的别人的博客,我不知道各位与我的情况是否一样,分享给大家:

第一步:在package.json中添加这两行代码:

"dev": "webpack --mode development",
"build": "webpack --mode production"

WARNING in configuration The 'mode' option has not been set, webpack will fallback to 'production' f_第1张图片

第二步:修改之前写的命令为:"npx webpack ./src/main.js --output-filename ./dist/bundle.js --output-path . --mode development "

WARNING in configuration The 'mode' option has not been set, webpack will fallback to 'production' f_第2张图片

结束

就这样简单

看见错误想砸电脑,解决之后想砸自己。。。。

你可能感兴趣的:(webpack,前端)