Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force page reload when reload needed. #180

Closed
chopfitzroy opened this issue Feb 28, 2017 · 4 comments
Closed

Force page reload when reload needed. #180

chopfitzroy opened this issue Feb 28, 2017 · 4 comments

Comments

@chopfitzroy
Copy link

I currently have a situation where I would like to disable HMR and just do a page reload when a file is changed, this is because of a current issue with Vue not working with the HMR when used with plain .js files as opposed to .vue files.

I have simply removed this line:

if (module.hot) {
    module.hot.accept();
}

which returns the following message in the console when files are changed:

[HMR] The following modules couldn't be hot updated: (Full reload needed)
This is usually because the modules which have changed (and their parents) do not know how to hot reload themselves. See http://webpack.github.io/docs/hot-module-replacement-with-webpack.html for more details.

Now in an ideal world I would like the browser to refresh when this message is showing is this something I can implement easily without removing webpack-hot-middleware I don't want to have to remove the plugin in the event that the above Vue issue is resolved.

Cheers.

@glenjamin
Copy link
Collaborator

Add reload=true to the querystring option of the client entry point in your webpack config.

@chopfitzroy
Copy link
Author

Hey @glenjamin I do have that and still seem to be running into this, out of curiosity could it be to do with electron?

@chopfitzroy
Copy link
Author

Hey @glenjamin actually scratch that I was passing reload: true through like so:

const settings = middleware(compiler, {
    publicPath: dev.output.publicPath,
    path: `http://${config.host}:${config.port}/__webpack_hmr`,
    reload: true,
    quiet: true
});

But when I added it like this:

base.entry.unshift(
    // hot-middleware allows us to still have HMR even when connected to the electron server
    `webpack-hot-middleware/client?reload=true`
);

It worked, any reason why this would be? And if so would it be possible to add to add it via the options objects I try to avoid the query string URL format.

@glenjamin
Copy link
Collaborator

The first one is adding config to the server, the second one is adding config to the client.

Reloading is a client setting, so has to be done on the client. If there's another way to pass config to client bundles like that i'm not aware of it - you'd have to ask around in webpack support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants