parcel: HMR for CSS doesn't refresh on subsequent entry pages and can also throw an error
๐ bug report
HMR for CSS doesnโt refresh on subsequent entry pages and can also throw an error.
๐ Configuration (.babelrc, package.json, cli command)
I created a repository to reproduce the error: https://github.com/gregorybolkenstijn/parcel-issue-hmr Steps to reproduce the issue:
- Clone the repository and run
yarn
- Run
yarn start
- In
main.scss
change the h1 background color to something else like blue. - The h1 background color gets refreshed via HMR
- Navigate to index2.html
- In
main.scss
change the h1 background color to something else like orange. - No visible changes, you have to reload to see the changes
Iโve noticed changes in HTML and JS do show, only CSS changes donโt. Iโve seen that CSS HMR only works on the first file Parcel encounters. If you run yarn start-glob
, youโll notice the CSS changes only show on home.html, not index.html or index2.html. Probably because home.html comes first alphabetically.
I have this problem as well in a more complex project with PostHTML and PostCSS transforms. The same setup is throwing an error instead of not refreshing the CSS:
app.ef966a9d.js:39 Uncaught Error: Cannot find module '../../../node_modules/parcel-bundler/src/builtins/css-loader.js'
at newRequire (app.ef966a9d.js:39)
at newRequire (app.ef966a9d.js:23)
at localRequire (app.ef966a9d.js:54)
at Object.eval (eval at hmrApply (app.js:1), <anonymous>:4:17)
at newRequire (app.ef966a9d.js:48)
at hmrAccept (app.js:1)
at app.js:1
at Array.forEach (<anonymous>)
at WebSocket.ws.onmessage (app.js:1)
๐ค Expected Behavior
Hot reloading works on all pages for all HTML, CSS/SCSS and JS changes.
๐ฏ Current Behavior
Doesnโt refresh on subsequent pages for CSS/SCSS changes.
๐ป Code Sample
https://github.com/gregorybolkenstijn/parcel-issue-hmr
๐ Your Environment
Software | Version(s) |
---|---|
Parcel | 1.9.7 |
Node | 10.8.0 |
npm/Yarn | 6.2.0 / 1.9.2 |
Operating System | 6.2.0 / 1.9.2 |
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 15
- Comments: 17 (2 by maintainers)
If the two HTML files donโt share a CSS file, but instead reference different CSS files, the bug goes away. Itโs the shared nature of the CSS which causes the problem.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs.
Iโm having this very same problem too, but I cannot even see one of the pages in the first place. The html is served fine, but without styles.
@DeMoorJasper I updated the bug report and title because I narrowed down the bug. I also made a repository so you can easily reproduce the bug. Hope this helps.