GitOfZGT / vite-plugin-theme-preprocessor

css theme preprocessor plugin for vite
MIT License
161 stars 15 forks source link

vite less 文件不能自定义变量 #43

Closed sanjinhub closed 2 years ago

sanjinhub commented 2 years ago
image image image

不知道为什么获取不到变量,引入 @import xxxx.less 是可以的,但是这样搞,不就不能动态切换了?

GitOfZGT commented 2 years ago

要把自定义的less,写在另外的文件,我在demo的注释有些说明 image

GitOfZGT commented 2 years ago

意思是, @test-color:#ccc; 写在 a.less, 然后哪里需要 就 @import "a.less"; image

sanjinhub commented 2 years ago

我知道这样是可以的,但是这样,无法动态切换了。如果自己写个,那就需要和大佬的插件出现两个切换主题的功能了。

GitOfZGT commented 2 years ago

我知道这样是可以的,但是这样,无法动态切换了。如果自己写个,那就需要和大佬的插件出现两个切换主题的功能了。

支持的,@test-color:#ccc; 写在 a.less, @test-color:#888; 写在 theme/default.less, 切换用

setCustomTheme({
     primary:"#878787", 
     gradientReplacer:{'#888':'#999'}
})
sanjinhub commented 2 years ago

我是这样干的,直接在 main.ts 全局引入 import "./theme/default.less"; ,然后就搞定了。 感谢作者,插件很棒,有赞赏的地方吗?

GitOfZGT commented 2 years ago

我是这样干的,直接在 main.ts 全局引入 import "./theme/default.less"; ,然后就搞定了。 感谢作者,插件很棒,有赞赏的地方吗?

没有,谢谢,多反馈问题就足矣!哈哈