import vue from '@vitejs/plugin-vue' import vueJsx from '@vitejs/plugin-vue-jsx' import { resolve } from 'path' import Components from 'unplugin-vue-components/vite' import { NaiveUiResolver } from 'unplugin-vue-components/resolvers' import { defineConfig, type ConfigEnv } from 'vite' // import { viteSingleFile } from 'vite-plugin-singlefile' // https://vitejs.dev/config/ export default defineConfig(({ command }: ConfigEnv) => { const isBuild = command === 'build' return ({ plugins: [ vue(), vueJsx(), Components({ resolvers: [NaiveUiResolver()] }), ], define: { __VUE_OPTIONS_API__: false // 关闭 Vue2 中的 options选项API }, base: './', // 使用相对路径 resolve: { alias: [{ find: '@', replacement: resolve(__dirname, 'src') }] }, server: { port: 6003, host: true, proxy: { '/api': { target: `http://127.0.0.1:16003/`, changeOrigin: true, rewrite: (path: string) => path.replace(/^\/api/, '') }, '/ws': { target: `ws://192.168.3.110:16003/`, changeOrigin: true, ws: true } } }, // Vite 8 原生方式:使用 Oxc Minifier 的 drop 选项 build: { rolldownOptions: { output: { minify: { compress: { dropConsole: isBuild, dropDebugger: isBuild, }, }, }, }, }, }) })