
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
vite-plugin-antd-theme
Advanced tools
vite 下的 antd-design-vue 主题生成插件,依赖 antd-theme-generator
vite.config.ts
// ...
import viteAntdTheme, { ThemeEntry, AntdThemeOptions } from 'vite-plugin-antd-theme';
// 从1.1.0之后,不提供该配置会默认导出antd提供的暗黑、默认及紧凑主题到src/config中。
const themesEntry: Array<ThemeEntry> = [
// 暗黑主题
{
entryPath: [
path.resolve(__dirname, './node_modules/ant-design-vue/lib/style/themes/dark.less'),
// v1.1.3版本后支持传入多个变量路径
// 比如项目中自定义的less变量
// 该功能由于读取变量时没有读取import的内容。
path.resolve(__dirname, './src/styles/dark.less')],
outputName: 'dark',
outputPath: './src/config'
},
// 默认主题
{
entryPath: './src/styles/vars.less',
outputName: 'light',
outputPath: './src/config'
},
// 紧凑主题
{
entryPath: './node_modules/ant-design-vue/lib/style/themes/compact.less',
outputName: 'compact',
outputPath: './src/config'
},
// ...其他自定义主题
];
const options: AntdThemeOptions = {
themesEntry,
// 是否提取全部变量,默认false,优先级低于设置themeVariables
allVariables: true,
// 以下是antd-theme-generator配置项
antdDir: path.join(__dirname, './node_modules/ant-design-vue'),
stylesDir: path.join(__dirname, './src'),
varFile: path.join(__dirname, './src/styles/vars.less'),
themeVariables: [],
outputFilePath: path.join(__dirname, './public/static/color.less')
customColorRegexArray: [/^fade\(.*\)$/]
};
export default ({ command }: ConfigEnv): UserConfigExport => {
return {
// ...
plugins: [
// ...
viteAntdTheme(options)
],
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true
}
}
}
};
};
index.html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>vite-plugin-antd-theme</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
<!--必须将引用放在最后,否则生成的主题会被其他覆盖-->
<link rel="stylesheet/less" type="text/css" href="/static/color.less" />
<script src="/static/libs/less.min.js"></script>
</body>
</html>
App.tsx(App.vue?)
// ...
import { defineComponent } from 'vue';
import 'ant-design-vue/dist/antd.less';
import darkVars from '@/config/dark.json';
export default defineComponent({
mounted() {
window.ddd = () => {
window['less'].modifyVars(darkVars).then(console.log);
};
},
setup() {
return () => <span>嗯嗯</span>;
},
});
// 测试
window.ddd();
2021-05-27 v1.1.0
从该版本开始默认支持导出 antd 三种主题配置文件到 src/config 目录下
FAQs
vite下的antd-design-vue主题生成插件
The npm package vite-plugin-antd-theme receives a total of 0 weekly downloads. As such, vite-plugin-antd-theme popularity was classified as not popular.
We found that vite-plugin-antd-theme demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.