{"id":13417399,"url":"https://github.com/vbenjs/vite-plugin-theme","last_synced_at":"2025-03-15T02:31:17.484Z","repository":{"id":37335196,"uuid":"335676940","full_name":"vbenjs/vite-plugin-theme","owner":"vbenjs","description":"Vite plugin for dynamically changing the theme color of the interface","archived":true,"fork":false,"pushed_at":"2023-07-20T02:42:07.000Z","size":446,"stargazers_count":140,"open_issues_count":22,"forks_count":35,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-07T10:38:35.264Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vbenjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-02-03T15:56:58.000Z","updated_at":"2025-02-12T09:16:40.000Z","dependencies_parsed_at":"2024-01-07T18:05:11.243Z","dependency_job_id":"79531a30-c69a-4b74-8b15-ece879c18216","html_url":"https://github.com/vbenjs/vite-plugin-theme","commit_stats":{"total_commits":43,"total_committers":5,"mean_commits":8.6,"dds":"0.41860465116279066","last_synced_commit":"29c8ef43864c555aa8422a92b08076e9673d08c4"},"previous_names":["anncwb/vite-plugin-theme"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbenjs%2Fvite-plugin-theme","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbenjs%2Fvite-plugin-theme/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbenjs%2Fvite-plugin-theme/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vbenjs%2Fvite-plugin-theme/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vbenjs","download_url":"https://codeload.github.com/vbenjs/vite-plugin-theme/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243674810,"owners_count":20329165,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T22:00:36.466Z","updated_at":"2025-03-15T02:31:17.162Z","avatar_url":"https://github.com/vbenjs.png","language":"TypeScript","funding_links":[],"categories":["Plugins"],"sub_categories":["Framework-agnostic Plugins"],"readme":"# vite-plugin-theme\n\n**English** | [中文](./README.zh_CN.md)\n\n[![npm][npm-img]][npm-url] [![node][node-img]][node-url]\n\nVite plugin for dynamically changing the theme color of the interface\n\nAfter 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\n\n### Install (yarn or npm)\n\n**node version:** \u003e=12.0.0\n\n**vite version:** \u003e=2.0.0\n\n```\nyarn add vite-plugin-theme -D\n```\n\nor\n\n```\nnpm i vite-plugin-theme -D\n```\n\n## Usage\n\n- Config plugin in vite.config.ts. In this way, the required functions can be introduced as needed\n\n```ts\nimport { defineConfig, Plugin } from 'vite';\nimport vue from '@vitejs/plugin-vue';\n\nimport { viteThemePlugin, mixLighten, mixDarken, tinycolor } from 'vite-plugin-theme';\n\nexport default defineConfig({\n  plugins: [\n    vue(),\n    viteThemePlugin({\n      // Match the color to be modified\n       colorVariables: [],\n    });\n  ],\n});\n```\n\n## Options\n\n`viteThemePlugin(Options)`\n\n**Options**\n\n| param | type | default | desc |\n| --- | --- | --- | --- |\n| colorVariables | `string[]` | - | If css contains the color value in the array, css will be extracted |\n| wrapperCssSelector | `string` | - | Universal outer selector. You can pass in'body' and other selectors to increase the level |\n| resolveSelector | `(selector:string)=\u003estring` | - | Custom selector conversion |\n| customerExtractVariable | `(css:string)=\u003estring` | - | Custom css matching color extraction logic |\n| fileName | `string` | `app-theme-style.hash.css` | File name output after packaging |\n| injectTo | `body` or `head` or `body-prepend` | `body` | The css loaded in the production environment is injected into the label body |\n\n## Sample project\n\n[Vben Admin](https://github.com/vbenjs/vue-vben-admin)\n\n## Reference project\n\n- [webpack-theme-color-replacer](https://github.com/hzsrc/webpack-theme-color-replacer)\n- [webpack-stylesheet-variable-replacer-plugin](https://github.com/eaTong/webpack-stylesheet-variable-replacer-plugin)\n\n## License\n\nMIT\n\n[npm-img]: https://img.shields.io/npm/v/vite-plugin-html.svg\n[npm-url]: https://npmjs.com/package/vite-plugin-html\n[node-img]: https://img.shields.io/node/v/vite-plugin-html.svg\n[node-url]: https://nodejs.org/en/about/releases/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvbenjs%2Fvite-plugin-theme","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvbenjs%2Fvite-plugin-theme","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvbenjs%2Fvite-plugin-theme/lists"}