English | 中文
Vite plugin for dynamically changing the theme color of the interface
After vite processes the css and dynamically analyzes the color value in the css text that matches the plug-in configuration, extract the specified color style code from all output css files. And create a app-theme-style.css file containing only color styles, dynamically insert it into the specified position (the bottom of the default body), and then replace the custom style/component library style color used with the new color, In order to achieve the purpose of dynamically changing the theme color of the project
node version: >=12.0.0
vite version: >=2.0.0
pnpm add @trinapower/vite-plugin-theme -D
- Config plugin in vite.config.ts. In this way, the required functions can be introduced as needed
import { defineConfig, Plugin } from 'vite';
import vue from '@vitejs/plugin-vue';
import { viteThemePlugin, mixLighten, mixDarken, tinycolor } from '@trinapower/vite-plugin-theme';
export default defineConfig({
plugins: [
vue(),
viteThemePlugin({
// Match the color to be modified
colorVariables: [],
});
],
});viteThemePlugin(Options)
Options
MIT
