-
Notifications
You must be signed in to change notification settings - Fork 5
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
Does it works with Hot Module Replacement? #1
Comments
Hi @nodkz, I don't have any mention of HMR in my files or webpack config, I just start the dev server with
and keep some other options (like devServer: {
contentBase: './build',
port: 8081
} I tried adding At the moment I have little idea of what's actually going on when a live reload happens. My guess is that live-reloading HTML (or even CSS) would require quite a different mechanism than live-reloading JS. The architecture of webpack seems to be very much focused on Javascript, so all plugins dealing with other file types in some way seem like a bit of a workaround. So I'm not sure if live-reloading the other stuff is even possible. I'll be happy to investigate further on this when I get some time :-) |
Yep, Webpack documentation is very hard and has many white spaces. package.json
{
scripts: {
"hot": "webpack-dev-server",
...
}
...
} which I start via terminal config['devServer'] = {
contentBase: './',
colors: true,
historyApiFallback: false, // when false, dev server make directory listing, good feature to navigate in project
hot: true,
inline: true,
progress: true,
port: 8008
}; Also in plugins I add config['plugins'].push(new webpack.HotModuleReplacementPlugin()); Now dev server has configured. So let configure entry points.config['entry']['nod.html'] = '/Users/nod/www/ps_whmcs/assets/_site/nod.html';
config['entry']['dev-hot-module-replacement'] = ['webpack/hot/only-dev-server', '/Users/nod/www/ps_whmcs/assets/_site/nod.html']; As you can see, first line is simple. But second line create So last point is my html file: <!DOCTYPE html>
<html>
<head>
<script src="http://localhost:8008/dist/dev-hot-module-replacement.js"></script>
</head>
<body>
<h1>344</h1>
</body>
</html> Here we add Now if we change content in entry html file, browser produces page reload. |
Try to use it with HMR:
In html file add
<script src="http://localhost:8008/webpack-dev-server.js"></script>
When I change the html file, it rebuilds in terminal.
In browser console:
But automatic page refresh does not apply.
Can you advise correct config for HMR?
The text was updated successfully, but these errors were encountered: