parcel: Hot reload doesn't work for an empty HTML page without external CSS/JS imports
🐛 bug report
No files or configs
🤔 Expected Behavior
I have empty HTML without any external resources (such as local CSS files or JS). When I change it and save I should get an immediate update in the browser without refresh while in dev mode.
😯 Current Behavior
I change anything in the HTML file, it gets rebuilt but not refreshed automatically in the browser. I need to click refresh.
💁 Possible Solution
When I add any import. For example <link> to the CSS external local file and then refresh the page once, all changes to HTML start to immediately displayed on saving without a need to press refresh
💻 Code Sample
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<p style="color: red">Hello world</p>
</body>
</html>
🌍 Your Environment
Software | Version(s) |
---|---|
Parcel | latest to date |
Node | 8.9.3 |
Yarn | 1.5 |
Operating System | Mac OS High Sierra |
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 19
- Comments: 15 (3 by maintainers)
Me too. JS reloads happen from my entry file, but if I modify the index.html file the page does NOT reload. Parcel v2.
There is no javascript bundle to append the HMR runtime to. https://github.com/parcel-bundler/parcel/blob/420ed63ed18c6a09e8b25754d0142b3b87ebcd71/src/packagers/JSPackager.js#L185-L191
We would have to inject a script tag into the html file.
💁 Possible Solution
if page has no one scripts, you must automatically add reload helper script, to the beginning of the head element, like:
Using
pug
with a conditional empty javascript file also worksI am still seeing HTML not be reloaded whether i have a script or not. I assume this shouldn’t be the case?
Interested by this feature.
I finally “solved” this by adding a live.js script into the
*.pug
pages. It does a good job at reloading the pages–might not be as fast as Parcel’s hmr, but it works.Don’t forget to remove this line when building for production.