Webpack-dev-server: Cannot apply update. Need to do a full reload! Javascript files only.

Created on 6 May 2019  路  5Comments  路  Source: webpack/webpack-dev-server

  • Operating System: Windows 10
  • Node Version: v10.15.3
  • NPM Version: 6.4.1
  • webpack Version: 3.3.0
  • webpack-dev-server Version: 3.1.10
  • browser: Chrome Version 74.0.3729.131 (Official Build) (64-bit)

  • [x] This is a bug

  • [ ] This is a modification request

Code

// webpack.config.js
devServer: {
    contentBase: path.join(__dirname, 'dist'),
    port: 9000,
    compress: true,
    hot: true,
    overlay: true,
    inline: true
}

Expected Behavior

HMR updates page without full reload

Actual Behavior

When I run webpack-dev-server --mode development --hot --inline any .js file change shows the following in the console:

[HMR] Cannot apply update. Need to do a full reload!
Error: Aborted because {file} is not accepted
Update propagation {file} -> 0

and then the whole page is reloaded losing state.

Changing CSS file works without any issue.

For Bugs; How can we reproduce the behavior?

Run webpack-dev-server and change any *.js file.

Most helpful comment

It is expected, your code doesn't have hmr logic, please read https://webpack.js.org/concepts/hot-module-replacement/ , if you use react you can use react-hot-loader (https://github.com/gaearon/react-hot-loader), for vue https://vue-loader.vuejs.org/guide/hot-reload.html, if you have own code please read article https://webpack.js.org/guides/hot-module-replacement/

All 5 comments

Please create minimum reproducible test repo

Why you use inline?

repo:
https://github.com/fret2buzz/webpack-dev

Why you use inline?

to see build messages in the browser console

You don't need inline to see build messages in the browser console

It is expected, your code doesn't have hmr logic, please read https://webpack.js.org/concepts/hot-module-replacement/ , if you use react you can use react-hot-loader (https://github.com/gaearon/react-hot-loader), for vue https://vue-loader.vuejs.org/guide/hot-reload.html, if you have own code please read article https://webpack.js.org/guides/hot-module-replacement/

Was this page helpful?
0 / 5 - 0 ratings