| | |
| | | import { defineConfig, loadEnv } from 'vite'; |
| | | import { CodeInspectorPlugin } from 'code-inspector-plugin'; |
| | | import { visualizer } from 'rollup-plugin-visualizer'; |
| | | import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'; |
| | | import AutoImport from 'unplugin-auto-import/vite'; |
| | | import Components from 'unplugin-vue-components/vite'; |
| | | // import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'; |
| | | // import AutoImport from 'unplugin-auto-import/vite'; |
| | | // import Components from 'unplugin-vue-components/vite'; |
| | | import viteCompression from 'vite-plugin-compression'; |
| | | import vueSetupExtend from 'vite-plugin-vue-setup-extend-plus'; |
| | | const pathResolve = (dir: string) => { |
| | |
| | | viteCompression({ |
| | | threshold: 1024000, |
| | | }), |
| | | AutoImport({ |
| | | resolvers: [ElementPlusResolver()], |
| | | }), |
| | | Components({ |
| | | resolvers: [ElementPlusResolver()], |
| | | }), |
| | | visualizer({ |
| | | gzipSize: true, |
| | | brotliSize: true, |
| | | emitFile: false, |
| | | filename: 'stats.html', //分析图生成的文件名 |
| | | |
| | | open: true, //如果存在本地服务端口,将在打包后自动展示 |
| | | }), |
| | | // AutoImport({ |
| | | // resolvers: [ElementPlusResolver()], |
| | | // }), |
| | | // Components({ |
| | | // resolvers: [ElementPlusResolver()], |
| | | // }), |
| | | // rollup-plugin-visualizer 打包分析,开启后,npm run build 自动打开打包后的模块图 |
| | | // visualizer({ |
| | | // gzipSize: true, |
| | | // brotliSize: true, |
| | | // emitFile: false, |
| | | // filename: 'stats.html', //分析图生成的文件名 |
| | | // open: true, //如果存在本地服务端口,将在打包后自动展示 |
| | | // }), |
| | | ], |
| | | root: process.cwd(), |
| | | resolve: { alias }, |
| | |
| | | port: env.VITE_PORT as unknown as number, |
| | | open: JSON.parse(env.VITE_OPEN), |
| | | hmr: false, |
| | | proxy: { |
| | | '/events': { |
| | | target: 'http://localhost:3000', |
| | | changeOrigin: true, |
| | | }, |
| | | /** @description 百度语音识别 */ |
| | | '/api/baidu/speech_recognition': { |
| | | target: 'https://aip.baidubce.com/rpc/2.0/tts/v1', |
| | | changeOrigin: true, |
| | | }, |
| | | /** @description 百度语音合成 */ |
| | | '/api/baidu/speech_synthesis': { |
| | | target: 'https://aip.baidubce.com/rpc/2.0/tts/v1', |
| | | changeOrigin: true, |
| | | rewrite: (path) => { |
| | | const newPath = path.replace('/api/baidu/speech_synthesis', ''); |
| | | return newPath; |
| | | }, |
| | | }, |
| | | }, |
| | | }, |
| | | build: { |
| | | // outDir: 'dist/' + mode.mode, |