import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import path from 'path' import { createSvgIconsPlugin } from 'vite-plugin-svg-icons' const baseUrl = { development: './', beta: './', release: './' } // https://vitejs.dev/config/ export default ({ mode }) => defineConfig({ plugins: [ vue(), createSvgIconsPlugin({ // 指定需要缓存的图标文件夹 iconDirs: [path.resolve(process.cwd(), 'src/assets/img/icons')], // 指定symbolId格式 symbolId: 'icon-[name]', }), ], base: baseUrl[mode], build: { minify: 'terser', terserOptions: { compress: { // 生产环境打包移除console drop_console: true, drop_debugger: true, } } }, resolve: { alias: { '~': path.resolve(__dirname, './'), '@': path.resolve(__dirname, 'src'), '@assets': path.resolve(__dirname, 'src/assets'), } }, css: { preprocessorOptions: { less: { additionalData: '@import "./src/assets/style/global.less";' } } }, server: { port: 8089, proxy: { '/api': { target: 'http://192.168.99.111:5001', changeOrigin: true, rewrite: path => path.replace(/^\/api/, '') } } } })