T
T
thehighhomie2018-02-01 19:32:09
JavaScript
thehighhomie, 2018-02-01 19:32:09

Webpack HMR: not updating js file or looping reload?

Straight to the point, here's the config, it's not big:

import path from 'path';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import BrowserSyncHotPlugin from 'browser-sync-dev-hot-webpack-plugin';
import webpack from 'webpack';

let webpackConfig = {
  entry: {
    app: [
      'webpack-hot-middleware/client',
      path.join(__dirname, 'src/js/app.js'),
      path.join(__dirname, 'src/sass/app.scss'),
    ]
  },

  output: {
    filename: 'js/[name].js',
    path: path.join(__dirname, 'dist'),
    publicPath: 'http://localhost:3000/'
  },

  module: {
    rules: [
      {
        test: /\.js$/,
        include: path.join(__dirname, 'src/js'),
        loader: "babel-loader"
      },
      {
        test: /\.scss$/,
        use: ExtractTextPlugin.extract({
          fallback: 'style-loader',
          use: ['css-loader', 'sass-loader']
        })
      }
    ]
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin(),
    new webpack.NoEmitOnErrorsPlugin(),
    new ExtractTextPlugin({
      filename: 'css/app.css',
      disable: true,
    }),
    new BrowserSyncHotPlugin({
      browserSync: {

        reloadDelay: 500,
        proxy: {
          target: 'http://gorch.loc/'
        },

        plugins: [
          {
            module: 'bs-html-injector',
            options: {
              files: './*.html'
            }
          }
        ]

      },
      devMiddleware: {
        publicPath: 'http://localhost:3000/'
      },
      hotMiddleware: {
        
      },
      callback() {
        console.log('Callback')
      }
    })
  ]
};

module.exports = webpackConfig;

The fact is that hmr perfectly updates htmk and sass files, but there is a problem with js, when you try to change the js file, nothing happens, but in the console it gives this:
5a734031863c9347213051.jpeg
even a full reload does not occur.
I was advised to add 'webpack-hot-middleware/client' to this, this is '?reload=true' but after that there is a cyclic reload of the page, endless ....
I dealt with the assembly with another person, he claims that when he updates js refreshes the page completely and everything is ok, but it disappeared somewhere and I can't handle it myself.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question