微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ReactJS + Webpack正在刷新页面而不是热加载

如何解决ReactJS + Webpack正在刷新页面而不是热加载

我使用webpack的react-redux项目未在浏览器中热加载。我必须手动刷新页面。不确定是什么问题。

我的项目网址是:https://super-chivalrous-asp.glitch.me

webpack日志正在跟踪

const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    entry: {
        bundle: ['babel-polyfill','./src/index.js'],},plugins: [
        new HtmlWebpackPlugin({ template: './index.html',minify: true }),],output: {
        filename: '[name].[hash].js',path: path.resolve(__dirname,'build'),publicPath: '/',resolve: {
        modules: [path.resolve(__dirname,'src'),'node_modules'],};

webpack.common.js

const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const common = require('./webpack.common.js');

module.exports = (env) => merge(common,{
    mode: 'development',devtool: 'eval-source-map',devServer: {
        contentBase: [path.join(__dirname,path.join(__dirname,'public')],hot: true,disableHostCheck: true,proxy: {
            '/superAdmin': {
                target: 'http://localhost:3001',secure: false,module: {
        rules: [
            {
                test: /\.(scss|css)$/,use: [
                    'style-loader','css-loader','resolve-url-loader',{ loader: 'sass-loader',options: { sourceMap: true } },{
                test: /\.(jpe?g|png|gif|woff|woff2|eot|ttf|svg)$/i,use: [
                    'file-loader',{
                test: /\.js$/,loader: 'babel-loader',exclude: /node_modules/,plugins: [
        new webpack.HotModuleReplacementPlugin(),new webpack.DefinePlugin({
            ENVIRONMENT: JSON.stringify(env)
        })
    ]
});

我的webpack.config.js

2.5

我检查了浏览器,它显示以下错误

enter image description here

注意:堆栈溢出中另一个类似问题的答案没有为我提供解决方案。 React + Webpack HMR is refreshing the page (not hot loading)

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。