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

HMR triggers a full reload when component styles change #4

Open
SilverMira opened this issue Feb 2, 2021 · 0 comments
Open

HMR triggers a full reload when component styles change #4

SilverMira opened this issue Feb 2, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@SilverMira
Copy link
Owner

Background

Plugin version: 2.3.0
When using style pre/post-processing through ngsnow, Snowpack's HMR will trigger a full reload on the browser when a style file changed, only changes in style files will trigger this behavior.

Reason

When using ngsnow, the plugin artificially requests a build from Snowpack to compile the style files for Angular's consumption, unfortunately, this triggers Snowpack to record this style file as potentially exists on the page despite it doesn't (Styles exists bundled within component.js in Angular, HMR-ing the component.js will suffice).

Snowpack's HMR Engine will fire a reload event since it thinks the css file is loaded in browser but there is no <style>.css.proxy.js loaded in the browser to accept the HMR module.

The code snippet in snowpack that causes this.
https://github.com/snowpackjs/snowpack/blob/41c29f25e53695ec84c07386af7eb140d0b22a8e/snowpack/src/commands/dev.ts#L1226-L1268

The code snippet in ngsnow that causes this.

server.loadUrl(finalResourceUrl);

Proposal

Unfortunately, it seems like there is no easy way to solve this currently other than implementing style pre/post-processing capabilities standalone within the plugin since we won't be requesting the files through Snowpack.

@SilverMira SilverMira added the bug Something isn't working label Feb 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant