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 doesn't work when using useCssModule with SSR #146

Open
7 tasks done
rvfakie opened this issue Apr 5, 2023 · 6 comments
Open
7 tasks done

HMR doesn't work when using useCssModule with SSR #146

rvfakie opened this issue Apr 5, 2023 · 6 comments
Labels
feat: hmr feat: ssr p3-minor-bug 🔨 An edge case that only affects very specific usage (priority)

Comments

@rvfakie
Copy link

rvfakie commented Apr 5, 2023

Describe the bug

Bug with HMR, CSS Modules and SCSS mixins imported with vite.

Please see reproduction and link to issue in nuxt.
@danielroe has also managed to reproduce this bug. I've attached his reproduction link.

After updating imported scss mixin in _buttons.scss styles for <button> just disappear.
Try to edit _buttons.scss style properties and you will see default button styles after HMR.

But if you modify app.vue after modifying _buttons.scss you will see HMR working correct.

Reproduction

https://stackblitz.com/edit/github-cbd5fr?file=vite.config.js

Steps to reproduce

No response

System Info

System:
    OS: macOS 13.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 116.52 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.17.1 - ~/.nvm/versions/node/v16.17.1/bin/node
    npm: 8.15.0 - ~/.nvm/versions/node/v16.17.1/bin/npm
  Browsers:
    Chrome: 111.0.5563.146
    Safari: 16.2

Used Package Manager

npm

Logs

No response

Validations

@stackblitz
Copy link

stackblitz bot commented Apr 5, 2023

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@sapphi-red
Copy link
Member

It seems SCSS is not necessary to reproduce.

It doesn't work when editing CSS module styles + using useCssModule + SSR.
https://stackblitz.com/edit/github-cbd5fr-qeqagm?file=src%2Fmain.ts,src%2FApp.vue

@sapphi-red sapphi-red added feat: hmr feat: ssr p3-minor-bug 🔨 An edge case that only affects very specific usage (priority) labels Apr 6, 2023
@sapphi-red sapphi-red changed the title HMR, CSS Module works not as expected after editing SCSS mixin in assets dir. HMR doesn't work when using useCssModule with SSR Apr 6, 2023
@Lustach
Copy link

Lustach commented Oct 24, 2023

Hello! If it only reproduce in ssr mode, is it possible to solve this problem?

@kier-mc
Copy link

kier-mc commented Jun 20, 2024

I'm experiencing the same issue. I'm using Nuxt (for context) with <style module lang="scss"> in SFCs. When I update my mixin.scss file in ./assets, all custom styles are removed from the target element, except for the reset I also apply from the same file, interestingly enough). Neither soft nor hard browser reloads will resolve the issue. I need to completely restart the server to resolve it. Editing app.vue as @rvfakie mentioned also works and saves time, but it would be great to see a more robust fix for this.

@Neoniq
Copy link

Neoniq commented Jul 18, 2024

Same here. Nuxt. but im not editing mixins like in comment above, im editing scss module.
Also, to reproduce: after page load change something in vue file, save, then change scss module > there you go, html class names stay same but in styles they changed.


  • Operating System: Windows_NT
  • Node Version: v20.14.0
  • Nuxt Version: 3.12.3
  • CLI Version: 3.12.0
  • Nitro Version: 2.9.7
  • Package Manager: pnpm@9.4.0
  • Builder: -
  • User Config: devtools, ssr, app, primevue, css, modules, swiper, icon, dir, components, srcDir, runtimeConfig, alias, compatibilityDate
  • Runtime Modules: @pinia/nuxt@0.5.1, @vueuse/nuxt@10.11.0, nuxt-primevue@3.0.0, @nuxt/icon@1.1.1, @nuxt/eslint@0.3.13, @nuxt/image@1.7.0, nuxt-swiper@1.2.2
  • Build Modules: -

@Matheun
Copy link

Matheun commented Jul 18, 2024

Exact same issue here.

When i change and save a file thats imported into my main.scss, the hmr wont update despite the terminal saying the hmr has updated.

Whenever i then save the main.scss, the styles on the frontend actually get updated, really need a fix for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat: hmr feat: ssr p3-minor-bug 🔨 An edge case that only affects very specific usage (priority)
Projects
None yet
Development

No branches or pull requests

6 participants