webpack 提示 Uncaught Error: [HMR] Hot Module Replacement is disabled

webpack打包完成页面未渲染出来提示:Uncaught Error: [HMR] Hot Module Replacement is disabled

const path = require('path')
const HTMLWebpackPlugin = require('html-webpack-plugin')
const webpack = require('webpack')

const isDev =process.env.NODE_ENV === 'development'

const config = {
  target:'web',
  entry:path.join(__dirname,'src/index.js'),
  output:{
    filename:'bundle.[hash:5].js',
    path:path.join(__dirname,'dist')
  },
  module:{
    rules:[
      {
        test:/\.vue$/,
        loader:'vue-loader'
      },
      {
        test:/\.css$/,
        use:[
          'style-loader',
          'css-loader'
        ]
      },
      {
        test:/\.styl/,
        use:[
          'style-loader',
          'css-loader',
          'stylus-loader'
        ]
      },
      {
        test:/\.(jpg|png|gif|jpeg|svg)$/,
        use:[
          {
            loader:'url-loader',
            options:{limit:1024,name:'[name]-[hash:5].[ext]'}
          }
        ]
      }
    ]
  },
  plugins:[
    new webpack.HotModuleReplacementPlugin(),
    new webpack.DefinePlugin({
      'process.env':{
        NODE_ENV: isDev ? '"development"' :'"production"'
      }
    }),
    new HTMLWebpackPlugin()
  ]
}


if(isDev){
  config.devServer = {
    port: 8000,
    host:'0.0.0.0',
    overlay:{
      error:true,
    }
  }
}

module.exports = config

plugins里添加

plugins:[

new webpack.HotModuleReplacementPlugin(),

]

 

你可能感兴趣的:(问题,打包工具)