初用webpack 报错The 'mode' option has not been set,

报错

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.
 

解决

初用webpack 报错The 'mode' option has not been set,_第1张图片

在package.json加入

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

初用webpack 报错The 'mode' option has not been set,_第2张图片

再重建一个名叫webpack.config.js的文件(位置在上图目录中)

写入

const  path=require("path");
module.exports = {
    entry: "./src/main.js",//入口文件路径
    output: {
        path: path.resolve(__dirname, './dist'),//处理过后的文件放置路径
        filename: "b.js"//该文件名字
    },
    mode: 'development'
}

你可能感兴趣的:(初用webpack 报错The 'mode' option has not been set,)