警告信息
终端输入webpack
对前端代码打包的时候出现了警告信息,如下:
asset bundle.js 305 bytes [emitted] [minimized] (name: main)
./src/main.js 117 bytes [built] [code generated]
./src/common.js 78 bytes [built] [code generated]
./src/utils.js 45 bytes [built] [code generated]
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 5.74.0 compiled with 1 warning in 309 ms
原因
需要指定自己打包的是生产环境还是测试环境,我这边做测试,所以在终端输入命令 webpack --mode=development
即可。如果是生产环境,使用命令webpack --mode=production
即可。
显示如下:
asset bundle.js 2.93 KiB [emitted] (name: main)
./src/main.js 117 bytes [built] [code generated]
./src/common.js 78 bytes [built] [code generated]
./src/utils.js 45 bytes [built] [code generated]
webpack 5.74.0 compiled successfully in 226 ms