vben
authored
|
1
2
3
4
|
/**
* Vite plugin for website theme color switching
* https://github.com/anncwb/vite-plugin-theme
*/
|
Vben
authored
|
5
|
import type { Plugin } from 'vite';
|
Vben
authored
|
6
|
import path from 'path';
|
Vben
authored
|
7
8
9
10
11
12
13
|
import {
viteThemePlugin,
antdDarkThemePlugin,
mixLighten,
mixDarken,
tinycolor,
} from 'vite-plugin-theme';
|
vben
authored
|
14
|
import { getThemeColors, generateColors } from '../../config/themeConfig';
|
Vben
authored
|
15
|
import { generateModifyVars } from '../../generate/generateModifyVars';
|
vben
authored
|
16
|
|
Vben
authored
|
17
|
export function configThemePlugin(isBuild: boolean): Plugin[] {
|
vben
authored
|
18
19
20
21
22
|
const colors = generateColors({
mixDarken,
mixLighten,
tinycolor,
});
|
Vben
authored
|
23
24
|
const plugin = [
viteThemePlugin({
|
Vben
authored
|
25
26
27
28
29
30
31
32
33
34
35
|
resolveSelector: (s) => {
s = s.trim();
switch (s) {
case '.ant-steps-item-process .ant-steps-item-icon > .ant-steps-icon':
return '.ant-steps-item-icon > .ant-steps-icon';
case '.ant-steps-item-icon > .ant-steps-icon':
return s;
}
return `[data-theme] ${s}`;
},
|
Vben
authored
|
36
37
38
|
colorVariables: [...getThemeColors(), ...colors],
}),
antdDarkThemePlugin({
|
Vben
authored
|
39
40
41
42
|
preloadFiles: [
path.resolve(process.cwd(), 'node_modules/ant-design-vue/dist/antd.less'),
path.resolve(process.cwd(), 'src/design/index.less'),
],
|
Vben
authored
|
43
|
filter: (id) => (isBuild ? !id.endsWith('antd.less') : true),
|
Vben
authored
|
44
45
46
47
48
49
50
51
52
|
// extractCss: false,
darkModifyVars: {
...generateModifyVars(true),
'text-color': '#c9d1d9',
'text-color-base': '#c9d1d9',
'component-background': '#151515',
// black: '#0e1117',
// #8b949e
'text-color-secondary': '#8b949e',
|
Vben
authored
|
53
|
'border-color-base': '#303030',
|
Vben
authored
|
54
|
// 'border-color-split': '#30363d',
|
Vben
authored
|
55
|
'item-active-bg': '#111b26',
|
Vben
authored
|
56
|
'app-content-background': 'rgb(255 255 255 / 4%)',
|
Vben
authored
|
57
58
59
60
61
|
},
}),
];
return (plugin as unknown) as Plugin[];
|
vben
authored
|
62
|
}
|