Vben
2021-04-08 96a49ba1163681465e735efd2273dac0c1bcf6ac
提交 | 用户 | age
07c18d 1 /**
V 2  * Vite plugin for website theme color switching
3  * https://github.com/anncwb/vite-plugin-theme
4  */
5b8eb4 5 import type { Plugin } from 'vite';
V 6 import {
7   viteThemePlugin,
8   antdDarkThemePlugin,
9   mixLighten,
10   mixDarken,
11   tinycolor,
12 } from 'vite-plugin-theme';
3d1681 13 import { getThemeColors, generateColors } from '../../config/themeConfig';
5b8eb4 14 import { generateModifyVars } from '../../generate/generateModifyVars';
3d1681 15
5b8eb4 16 export function configThemePlugin(isBuild: boolean): Plugin[] {
3d1681 17   const colors = generateColors({
V 18     mixDarken,
19     mixLighten,
20     tinycolor,
21   });
5b8eb4 22   const plugin = [
V 23     viteThemePlugin({
24       resolveSelector: (s) => `[data-theme] ${s}`,
25       colorVariables: [...getThemeColors(), ...colors],
26     }),
27     antdDarkThemePlugin({
96a49b 28       filter: (id) => (isBuild ? !id.endsWith('antd.less') : true),
5b8eb4 29       // extractCss: false,
V 30       darkModifyVars: {
31         ...generateModifyVars(true),
32         'text-color': '#c9d1d9',
33         'text-color-base': '#c9d1d9',
34         'component-background': '#151515',
35         // black: '#0e1117',
36         // #8b949e
37         'text-color-secondary': '#8b949e',
6b9962 38         // 'border-color-base': '#30363d',
V 39         // 'border-color-split': '#30363d',
5b8eb4 40         'item-active-bg': '#111b26',
V 41       },
42     }),
43   ];
44
45   return (plugin as unknown) as Plugin[];
3d1681 46 }