| 1 | import { fileURLToPath, URL } from 'node:url' |
| 2 | |
| 3 | import { defineConfig } from 'vite' |
| 4 | import vue from '@vitejs/plugin-vue' |
| 5 | import svgLoader from 'vite-svg-loader' |
| 6 | import AutoImport from 'unplugin-auto-import/vite' |
| 7 | import Components from 'unplugin-vue-components/vite' |
| 8 | import { ElementPlusResolver } from 'unplugin-vue-components/resolvers' |
| 9 | import ElementPlus from 'unplugin-element-plus/vite' |
| 10 | |
| 11 | // https://vitejs.dev/config/ |
| 12 | export default defineConfig({ |
| 13 | base: '', |
| 14 | plugins: [ |
| 15 | vue(), |
| 16 | svgLoader(), |
| 17 | ElementPlus({}), |
| 18 | AutoImport({ |
| 19 | resolvers: [ElementPlusResolver()], |
| 20 | }), |
| 21 | Components({ |
| 22 | resolvers: [ElementPlusResolver()], |
| 23 | }), |
| 24 | ], |
| 25 | resolve: { |
| 26 | alias: { |
| 27 | '@': fileURLToPath(new URL('./src', import.meta.url)), |
| 28 | '@shared': fileURLToPath(new URL('../shared', import.meta.url)), |
| 29 | }, |
| 30 | dedupe: ['vue', 'element-plus', '@element-plus/icons-vue'], |
| 31 | modules: [ |
| 32 | fileURLToPath(new URL('../node_modules', import.meta.url)), |
| 33 | 'node_modules', |
| 34 | ], |
| 35 | }, |
| 36 | css: { |
| 37 | preprocessorOptions: { |
| 38 | scss: { |
| 39 | api: 'modern', |
| 40 | additionalData: `@use "@shared/css/_index.scss" as *;`, |
| 41 | }, |
| 42 | }, |
| 43 | }, |
| 44 | build: { |
| 45 | assetsDir: '', |
| 46 | chunkSizeWarningLimit: 1000, |
| 47 | minify: 'terser', |
| 48 | terserOptions: { |
| 49 | compress: { |
| 50 | drop_console: true, |
| 51 | drop_debugger: true, |
| 52 | }, |
| 53 | }, |
| 54 | }, |
| 55 | server: { |
| 56 | allowedHosts: process.env.ALLOWED_HOSTS |
| 57 | ? process.env.ALLOWED_HOSTS.split(',') |
| 58 | : [], |
| 59 | proxy: { |
| 60 | '/api': { |
| 61 | target: process.env.VITE_API_URL || 'http://127.0.0.1:7500', |
| 62 | changeOrigin: true, |
| 63 | }, |
| 64 | }, |
| 65 | }, |
| 66 | }) |