question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

vite plugin does not support HMR for vite >= 2.5.0

See original GitHub issue

Describe the bug

I’ve created a fresh vite project via yarn create vite vite-vanilla-extract-test --template react- ts and set up vanilla extract. Here’s the vite.config.ts:

import {defineConfig} from "vite";
import reactRefresh from "@vitejs/plugin-react-refresh";
import {vanillaExtractPlugin} from "@vanilla-extract/vite-plugin";

export default defineConfig({
  plugins: [reactRefresh(), vanillaExtractPlugin()],
})

Changing any file css.tsx leads to a full refresh of the page which makes iterating on styles rather cumbersome.

For experimentation, I’ve created a *.module.css file. And here it does work as expected and you’ll find this line in the logs: image

Not sure whether it’s a known limitation of the plugin. In that case it might be worth mentioning it in the README.

On the plus side it seems like you can remove the There are currently no automatic readable class names warning as it seems to be working with the latest version 🙂

image

System Info

System:
    OS: macOS 10.15.7
    CPU: (6) x64 Intel(R) Core(TM) i5-8500B CPU @ 3.00GHz
    Memory: 1.33 GB / 20.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 14.15.4 - /usr/local/bin/node
    Yarn: 1.22.10 - ~/.npm-global/bin/yarn
    npm: 6.14.10 - /usr/local/bin/npm
  Browsers:
    Brave Browser: 88.1.20.110
    Chrome: 93.0.4577.63
    Firefox: 87.0
    Safari: 14.1.2
  npmPackages:
    @vanilla-extract/vite-plugin: ^2.0.2 => 2.0.2 
    vite: ^2.5.4 => 2.5.6 

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:15 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
mattcompilescommented, Sep 21, 2021

Just released @vanilla-extract/vite-plugin v2.1.0. It allows you to switch the style runtime from the vite one to the vanilla-extract one. Try passing devStyleRuntime: 'vanilla-extract' and let me know if the HMR experience improves. We may move to it by default if it results in a better dev experience.

1reaction
mattcompilescommented, Oct 19, 2021

With the release of v3 of the vite-plugin all known HMR issues should now be working. 🙌

Read more comments on GitHub >

github_iconTop Results From Across the Web

vite plugin does not support HMR for vite >= 2.5.0 #346 - GitHub
Ah this seems like a regression within vite: HMR works fine for vite 2.4.4 but breaks with 2.5.0.
Read more >
Features | Vite
Vue users should use the official @vitejs/plugin-vue-jsx plugin, which provides Vue 3 specific features including HMR, global component resolving, directives ...
Read more >
Troubleshooting - Vite
If HMR is not handled by Vite or a plugin, a full reload will happen. ... Vite cannot handle and does not support...
Read more >
Vite 4.0 is out!
Storybook announced first-class support for Vite as one of its main features for Storybook 7.0. Deno now supports Vite. Vitest adoption is exploding,...
Read more >
Plugin API - Vite
When creating a plugin, you can inline it in your vite.config.js . There is no need to create a new package for it....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found