vbenjs / vite-plugin-theme

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

fix(darkTheme): fix when config.base has protocal, generate wrong lin… #16

Closed ZeyanGuo closed 2 years ago

ZeyanGuo commented 2 years ago

问题描述:

当使用vben时,配置生成环境变量为:

......

# public path, please set to deployed server address
VITE_PUBLIC_PATH = http://localhost:5500/ #此处带上协议信息

......

最终打包出的暗黑主题样式为:

......
<link disabled id=__VITE_PLUGIN_THEME-ANTD_DARK_THEME_LINK__ rel="alternate stylesheet" href=http:/localhost:5500/assets/app-antd-dark-theme-style.e3b0c442.css>
......

此处http协议少了一个反斜杠,导致资源请求不到。

问题原因:

node的path.join方法会将http://给过滤成http:/,因此需要对添加协议的设置做特殊处理。

主要修改内容:

增加针对协议的处理内容,主要修改src/antdDarkThemePlugin.ts文件。