#3784·snowpack

BUG: css.proxy.js files do not receive updates with `snowpack build --watch`

Author: smnhgnCreated Oct 23, 2021Updated May 29, 2023

Quick checklist

  • I am using the latest version of Snowpack and all plugins.

What package manager are you using?

npm

What operating system are you using?

Windows

Describe the bug

Projects which are set up with snowpack and @snowpack/plugin-sass and directly import sass files in js (or ts) will generate css.proxy.js files in their build output. With snowpack build --watch the css.proxy.js files will not receive updates after changes to the sass files.

Steps to reproduce

  1. set up project with snowpack and @snowpack/plugin-sass
  2. import sass file in js (or ts) import "./index.scss"
  3. run build with watch flag snowpack build --watch
  4. change contents of sass file (index.scss) body { background: blue; } -> body { background: red; }
  5. check build output
  6. css output (index.css) received update
    body { background: red; }
  7. css proxy output (index.css.proxy.js) did not receive update
if (typeof document !== 'undefined') {
  const code = "body {\n  background: blue;\n}";

  const styleEl = document.createElement("style");
  const codeEl = document.createTextNode(code);
  styleEl.type = 'text/css';
  styleEl.appendChild(codeEl);
  document.head.appendChild(styleEl);
}

Link to minimal reproducible example (optional)

https://github.com/smnhgn/snowpack-css-proxy-bug