Skip to content

HMR triggers a full reload when component styles change #4

Description

@SilverMira

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions