ttk-cli / uni-vue3-vite-ts-pinia

A template for uniapp with vue3.
MIT License
331 stars 100 forks source link

关于打包微信小程序运行报错 [ WXSS 文件编译错误] ./app.wxss unexpected token "*"问题 #35

Closed wobushirunning closed 1 year ago

wobushirunning commented 1 year ago

打包微信小程序运行报错 [ WXSS 文件编译错误] ./app.wxss unexpected token "*",此问题可以通过在unocss.config.ts中设置theme: {preflightRoot: ['page,::before,::after']}来解决,同时由于小程序不支持 \ \: [ \$ . [等转义类名,bg-#81ecec例如这种,同样会在运行时报错,可使用unocss-preset-weapp解决小程序不兼容的相关问题.

wobushirunning commented 1 year ago

配置如下:

image
Allen-1998 commented 1 year ago

感谢分享,晚点我会验证一下

jocstech commented 1 year ago

这个问题一定要优化解决,uni的主要优势就是可以编译小程序。

Allen-1998 commented 1 year ago

关于解决小程序不兼容unocss语法的问题,目前看下来社区解决方案比较不错的有两个插件 unocss-applet unocss-preset-weapp, 由于无法确定社区项目的稳定性,是否会长期维护,所以个人觉得还是不要过早将它集成到此模版会好一些,后期如果可以有一个库维护的比较不错,被 unocss 集成到 core 或者推荐的话,再集成进来会比较合适,当然如果你想在自己的项目中使用的话也是没问题的,我觉得这两个插件都做的很不错

编译wxss报错的问题已修复进主分支,再次感谢分享!