question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HMR not working as expected, reloads page instead

See original GitHub issue

Hot reloading components does not work at the moment (used to work just fine).

Describe the issue / bug.

When setting up a new project, hot reloading does not work. It used to work, I have a project from about 2 weeks ago (setup the same way) where it works just fine.

How can I reproduce this problem?
  • Setup a new project: vue init simulatedgreg/electron-vue my-project
  • Install dependencies: yarn
  • Start: yarn run dev
  • Make a change in the HTML of a component, eg. change a text in src/renderer/components/LandingPage/SystemInformation.vue

It will reload the whole app instead of hot-reloading the component.

Tell me about your development environment.
  • Node version: 8.4.0
  • NPM version: 5.5.1
  • Yarn version: 1.0.1
  • vue-cli version: 2.9.1
  • Operating System: Darwin

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:3
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

42reactions
nwittwercommented, Aug 25, 2019

After quite some time looking for a solution to this on my own project, I realized that the webpack-dev-server package actually has a built-in option for HMR (hot module reloading), so it may not be necessary to use the additional webpack-hot-middleware from the current setup. Simply adding hot: true to the Webpack Dev Server options made it all work as you’d expect—see below for example change.

Open up .electron-vue/dev-runner.js and change from

const server = new WebpackDevServer(
      compiler,
      {
        contentBase: path.join(__dirname, '../'),
        quiet: true,
        before (app, ctx) {
          app.use(hotMiddleware)
          ctx.middleware.waitUntilValid(() => {
            resolve()
          })
        }
      }
    )

to

const server = new WebpackDevServer(
      compiler, {
        contentBase: path.join(__dirname, '../'),
        quiet: true,
        hot: true, // <-- the fix!
        before(app, ctx) {
          // app.use(hotMiddleware) // <-- not necessary!
          ctx.middleware.waitUntilValid(() => {
            resolve()
          })
        }
      }
    )

There’s more details about the hot option here: https://webpack.js.org/configuration/dev-server/#devserverhot.

NOTE: I’ve updated a few versions from this template’s default versions: Electron 6.0.4, Webpack 4.39.2, webpack-dev-server 3.8.0

7reactions
rmartinmcommented, Oct 28, 2017

I have the same issue. I found a workaround, In the file dev-client.js i commented line 8 (window.location.reload()) And HMR work as espected.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React + Webpack HMR is refreshing the page (not hot loading)
I just ran into this problem. A couple things: To help debug your particular issue, try enabling "Preserve log" (in Chrome dev tools)....
Read more >
Hot Module Replacement - webpack
Hot Module Replacement (or HMR) is one of the most useful features offered by webpack. It allows all kinds of modules to be...
Read more >
Problem: Live reloading isn't refreshing for Webpack 5
While in the terminal I noticed things updating, the page wouldn't automatically refresh. This turns out to be a small bug with how...
Read more >
Set up React Hot Loader in 10 minutes - LogRocket Blog
HMR solves the problem of hot reloading, makes it easier to tweak ... the application does a live reload and the entire page...
Read more >
HMR: See Changes without Reloading - SymfonyCasts
I'll move over and reload the page one time just to be safe. ... HMR isn't working for styles. ... Instead, it embeds...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found