webpack实现修改代码实时刷新浏览器

时间:2022-12-05 23:23:32

webpack例子:https://github.com/Aquarius1993/webpackDemo

1. 需要全局和项目安装webpack和webpack-dev-server

npm install webpack webpack-dev-server -g
npm install webpack webpack-dev-server --save-dev

2. 配置webpack.config.js

// 服务器配置相关  自动刷新
    devServer: {
        historyApiFallback: true,
        hot: false,
        inline: true,
        grogress: true
    },

3. 运行项目

//调试
webpack-dev-server --inline
//打包
webpack