vbenjs / vite-plugin-theme

Vite plugin for dynamically changing the theme color of the interface
MIT License
140 stars 35 forks source link

建议css正则配置可以抽离到全局options中 #5

Closed xxholly32 closed 3 years ago

xxholly32 commented 3 years ago

https://github.com/anncwb/vite-plugin-theme/blob/main/client/client.ts#L138 正则匹配可能会有一些定制化的需求吧,我建议能够放开一些

我在使用tailwindcss的时候会有一些奇怪的匹配,举个比较简单的例子:

<style id="__VITE_PLUGIN_THEME__">
 .bg-primary {
    background-color:#ec4899
}
.hover\:bg-primary-hover:hover {
    background-color:#f472b6
}
</style>

bg-primary 会生效,但 hover\\:bg-primary-hover:hover 应该改为 hover\:bg-primary-hover:hover

未知的情况会比较多,希望 replace 的方式可以全局抛出来,或者满足一下特殊的需求

anncwb commented 3 years ago

升级到0.8.0,尝试使用customCssHandler这个试试

xxholly32 commented 3 years ago

这个只有 prod 环境才有效果,dev 环境下 renderTheme 中的 replaceCssColors 入参还是2个 https://github.com/anncwb/vite-plugin-theme/blob/main/client/client.ts#L84

xxholly32 commented 3 years ago

个人建议还要加个 customCssHandler 到全局配置中 😢