美文网首页
[HMR] Hot Module Replacement is

[HMR] Hot Module Replacement is

作者: 胡儒清 | 来源:发表于2018-08-30 05:42 被阅读48次

    webpack配置

    let path = require('path');
    let htmlWebpackPlugin = require('html-webpack-plugin');
    const webpack = require('webpack');
    const CleanWebpackPlugin = require('clean-webpack-plugin');
    
    module.exports = {
        entry: './main.js',
        output: {
            path: path.resolve(__dirname, 'dist'),
            filename: 'bundle.js'
        },
        mode: 'development',
        devtool: 'inline-source-map',
        devServer: {
            contentBase: './dist',
            hot: true
        },
        plugins: [
            new htmlWebpackPlugin(),
            new CleanWebpackPlugin(['dist']),
            new webpack.NamedModulesPlugin(),
            new webpack.HotModuleReplacementPlugin()
        ]
    }
    

    一切都是安装文档配置,结果报了个错: [HMR] Hot Module Replacement is disabled.
    查了stackoverflow,需要在启动的时候加上下面这一句

    --hot --inline
    package.json配置如下:
    "start": "webpack-dev-server --hot --inline --open"
    

    相关文章

      网友评论

          本文标题:[HMR] Hot Module Replacement is

          本文链接:https://www.haomeiwen.com/subject/cfglwftx.html