//配置代理跨域等 // vite.config.ts import { defineConfig } from 'vite' import { createSvgIconsPlugin } from 'vite-plugin-svg-icons' import { viteMockServe } from 'vite-plugin-mock' import vue from '@vitejs/plugin-vue' import path from 'path' export default defineConfig(({ command }) => { return { plugins: [ vue(), createSvgIconsPlugin({ // Specify the icon folder to be cached iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')], // Specify symbolId format symbolId: 'icon-[dir]-[name]', }), viteMockServe({ enable: command === 'serve', //保证开发阶段可以使用mock接口 }), ], resolve: { alias: { '@': path.resolve('./src'), // 相对路径别名配置,使用 @ 代替 src }, }, //scss全局变量的配置 css: { preprocessorOptions: { scss: { javascriptEnabled: true, additionalData: '@import "./src/styles/variable.scss";', }, }, }, } })