Skip to content

设置 include unocss 无法转换 #33

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

Open
AuYuHui opened this issue Apr 24, 2024 · 15 comments
Open

设置 include unocss 无法转换 #33

AuYuHui opened this issue Apr 24, 2024 · 15 comments

Comments

@AuYuHui
Copy link

AuYuHui commented Apr 24, 2024

image

@wswmsword
Copy link
Owner

可能顺序要变一下,试下把 unocssPs() 放到数组最后行不行。

@AuYuHui
Copy link
Author

AuYuHui commented Apr 24, 2024

不行,试了

@AuYuHui
Copy link
Author

AuYuHui commented Apr 24, 2024

设置 include 后 媒体查询模式页失效

@wswmsword
Copy link
Owner

include 的逻辑我记得是只有 include 包括的页面才转换,其他页面不转换,你的意思是 include 里的页面(/views/mobile-detail)没有转换成媒体查询最大宽度吗?

@AuYuHui
Copy link
Author

AuYuHui commented Apr 24, 2024

s

include 的逻辑我记得是只有 include 包括的页面才转换,其他页面不转换,你的意思是 include 里的页面(/views/mobile-detail)没有转换成媒体查询最大宽度吗?

是的,

@wswmsword
Copy link
Owner

unocssPs() 去掉就能转换吗?

@AuYuHui
Copy link
Author

AuYuHui commented Apr 24, 2024

unocssPs() 去掉就能转换吗?

也不行。

@wswmsword
Copy link
Owner

ok,我最近有点忙,会抽空看下,可能回复较慢,我主要看下我本地运行 include 会不会转换包括的文件,不转换不包括的文件,如果能验证可能就是你的 include 路径有问题了。

@wswmsword
Copy link
Owner

您的操作系统是 Windows 吗,是的话正则匹配要注意路径分隔符号,include: /views[\\/]mobile-detail/,这样再试试。

写了个只有 include 的范例,不会转换 include 以外的文件。

@zalinx
Copy link

zalinx commented Apr 9, 2025

请问这个有解决方法了吗?项目中使用unocss,若设置include路径的话,这个路径中class的px会进行转换,但是该路径中使用到unocss,比如font-[12px]这些class都不能转换

@wswmsword
Copy link
Owner

是所有 UnoCSS 单位都不能转换吗,vue3-vant-mobile 这个模板也用了 UnoCSS,你看能不能参考下。

@zalinx
Copy link

zalinx commented Apr 9, 2025

是所有 UnoCSS 单位都不能转换吗,vue3-vant-mobile 这个模板也用了 UnoCSS,你看能不能参考下。

是的,如果不使用include的话,项目中unocss单位都是可以转换的。使用了include,指定某些文件路径,这个路径下的文件,自己写的class,px会转换成vw,但是这个文件中使用的unocss单位都不会进行转换

@zalinx
Copy link

zalinx commented Apr 9, 2025

是所有 UnoCSS 单位都不能转换吗,vue3-vant-mobile 这个模板也用了 UnoCSS,你看能不能参考下。

是的,如果不使用include的话,项目中unocss单位都是可以转换的。使用了include,指定某些文件路径,这个路径下的文件,自己写的class,px会转换成vw,但是这个文件中使用的unocss单位都不会进行转换

如果在include中多添加匹配 /__uno.css 的话,unocss单位可以转换,但是设置这个的话,好像整个项目都受影响,无法达到只处理某个文件这个预期

@wswmsword
Copy link
Owner

是不是 UnoCSS 会把所有的样式在编译的时候先放到一个中间产物文件里,就是放到 __uno.css

@zalinx
Copy link

zalinx commented Apr 11, 2025

是不是 UnoCSS 会把所有的样式在编译的时候先放到一个中间产物文件里,就是放到 __uno.css

应该是,我之前unocss的样式直接写在行内,编译打包后不在当前文件路径,include指定的路径就无法转换,后面把unocss用@apply的方式写在style中,就可以转换了,已解决问题,谢谢哈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants