webpck打包The 'mode' option has not been set, webpack will fallback to 'production' for this value

打包报如下错误: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.

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/concepts/mode/

解决方法:

1、在package.json中添加: --mode development,–mode production

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "dev": "webpack-dev-server --open --mode development",
    "build": "webpack --mode production"
  },

2、在webpack.config.js中设置:mode: ‘development’

module.exports = {
   entry: "./src/main.js",
    output: {
       path: path.resolve(__dirname, 'dist'),
       filename: "demo.js"
    },
    mode: 'development' // 设置mode
}
3、下载指定版本

npm install -D webpack@3 // 3 :webpack版本3最新



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