import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import path from 'path' import AutoImport from 'unplugin-auto-import/vite' import Components from 'unplugin-vue-components/vite' import { ElementPlusResolver } from 'unplugin-vue-components/resolvers' // https://vitejs.dev/config/ export default defineConfig({ plugins: [vue(), AutoImport({ resolvers: [ElementPlusResolver({ importStyle: 'sass' })], }), Components({ resolvers: [ElementPlusResolver({ importStyle: 'sass' })], }) ], resolve: { alias: { '@': path.resolve(__dirname, 'src'), 'views': path.resolve(__dirname, 'src', 'views'), 'components': path.resolve(__dirname, 'src', 'components') } }, css: { preprocessorOptions: { scss: { additionalData: `@use "@/theme.scss" as *;`, }, }, }, })
1. 自动导入的时候, 样式要选择sass
2. 使用css预处理器, 编译自定义的主题, 会和 element-plus 的主题合并
@forward "element-plus/theme-chalk/src/common/var.scss" with ($colors: ("primary": ("base": #ff6700, ), "success": ("base": #3dc54b, ), ));
标签:src,ElementPlus,resolve,样式,theme,vue,path,import From: https://www.cnblogs.com/fmg0224/p/17275224.html