import vue from '@vitejs/plugin-vue' import path from 'path' import { ConfigEnv, defineConfig, UserConfigExport } from 'vite' import Components from 'unplugin-vue-components/vite'; import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'; import { viteVConsole } from 'vite-plugin-vconsole' export default ({ command, mode }: ConfigEnv): UserConfigExport => defineConfig({ base: '/', css: { preprocessorOptions: { scss: { additionalData: '@import "./src/styles/variables";' }, } }, resolve: { alias: [ { find: '/@', replacement: path.resolve(__dirname, './src'), } ] }, server: { open: true, host: '0.0.0.0', port: 8080 }, build: { target: ['es2015'], // 最低支持 es2015 sourcemap: true }, plugins: [ vue(), Components({// 自动导入组件 resolvers: [AntDesignVueResolver({ importStyle: false })], dts: 'src/typings/components.d.ts' }), viteVConsole({ entry: path.resolve(__dirname, './src/main.ts'), // 入口文件 localEnabled: command === 'serve', // serve开发环境下 // enabled: command !== 'serve' || mode === 'test', // 打包环境下/发布测试包, config: { // vconsole 配置项 maxLogNumber: 1000, theme: 'light' } }), ], })