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

[Bug]: UnoCSS HMR does not work #3528

Closed
bosens-China opened this issue Sep 22, 2024 · 3 comments · Fixed by unocss/unocss#4161
Closed

[Bug]: UnoCSS HMR does not work #3528

bosens-China opened this issue Sep 22, 2024 · 3 comments · Fixed by unocss/unocss#4161
Labels
🐞 bug Something isn't working 🎯 upstream

Comments

@bosens-China
Copy link

Version

System:
    OS: Windows 11 10.0.22631
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 17.30 GB / 31.86 GB
  Browsers:
    Edge: Chromium (128.0.2739.54)
    Internet Explorer: 11.0.22621.3527
  npmPackages:
    @rsbuild/core: ^1.0.1 => 1.0.5
    @rsbuild/plugin-less: ^1.0.1 => 1.0.1
    @rsbuild/plugin-react: ^1.0.1 => 1.0.2

Details

  1. 按照文档安装 https://rsbuild.dev/zh/guide/basic/unocss
  2. 在项目中使用class类名
  3. 浏览器没有正确显示

Reproduce link

https://github.com/bosens-China/picture-bed/tree/master/packages/interface

Reproduce Steps

  1. 克隆这个项目
  2. pnpm install
  3. cd /packages/interface
  4. pnpm run dev
  5. 随便在文件任意位置添加class,例如p-32px
  6. 观察浏览器style注入情况
@bosens-China bosens-China added the 🐞 bug Something isn't working label Sep 22, 2024
@bosens-China bosens-China changed the title [Bug]: UnoCSS使用的时候hmr不起作用 [Bug]: hmr下UnoCSS不起作用 Sep 22, 2024
@chenjiahan chenjiahan changed the title [Bug]: hmr下UnoCSS不起作用 [Bug]: UnoCSS HMR does not work Sep 22, 2024
@9aoy
Copy link
Collaborator

9aoy commented Sep 23, 2024

Turn on the hmr configuration in your project, everything looks fine.

https://github.com/bosens-China/picture-bed/blob/master/packages/interface/rsbuild.config.ts#L17

image

@bosens-China
Copy link
Author

bosens-China commented Sep 24, 2024

@9aoy 我录制了一个视频你可以看下,复线步骤

  1. 开启hmr
  2. 在一个新的元素,直接添加classname
  3. https://cdn.z.wiki/autoupload/20240924/pcQ2/%E5%BD%95%E5%B1%8F2024-09-24_14.29.48.mov

@9aoy
Copy link
Collaborator

9aoy commented Sep 25, 2024

This problem is caused by the recent version of @unocss/postcss not adding the postcss dependency correctly. Needs to be fixed in @unocss/postcss.

image

unocss/unocss@3ccd4c8#diff-4693bd37b5c3bdb6333760a51bd95d59c108fe0893e24e1237babd281d8b01e4R138-R153

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working 🎯 upstream
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants