A8000
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.4 KiB

8 months ago
7 months ago
8 months ago
7 months ago
7 months ago
8 months ago
7 months ago
3 months ago
7 months ago
4 months ago
7 months ago
8 months ago
  1. import { defineConfig } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import { fileURLToPath, URL } from 'url'
  4. import AutoImport from 'unplugin-auto-import/vite'
  5. import Components from 'unplugin-vue-components/vite'
  6. import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
  7. import packageJson from './package.json'
  8. // https://vitejs.dev/config/
  9. export default defineConfig({
  10. define: {
  11. __APP_VERSION__: JSON.stringify(packageJson.version),
  12. 'import.meta.env.VITE_APP_VERSION': JSON.stringify(packageJson.version)
  13. },
  14. base: './',
  15. plugins: [
  16. vue(),
  17. AutoImport({
  18. resolvers: [ElementPlusResolver({ importStyle: false })],
  19. }),
  20. Components({
  21. resolvers: [ElementPlusResolver({ importStyle: false })],
  22. }),
  23. ],
  24. resolve: {
  25. extensions: ['.js', '.ts', '.vue', '.json'], // 添加 .ts 扩展名解析
  26. alias: {
  27. '@': fileURLToPath(new URL('./src', import.meta.url)), // 确保将 @ 指向 src 目录
  28. },
  29. },
  30. build: {
  31. outDir: `dist-v${packageJson.version}`,
  32. minify: 'terser',
  33. terserOptions: {
  34. compress: {
  35. drop_console: true,
  36. drop_debugger: true,
  37. },
  38. },
  39. },
  40. server: {
  41. port: 5173,
  42. host: '0.0.0.0',
  43. proxy: {
  44. '/api': {
  45. target: 'http://localhost:8888',
  46. changeOrigin: true,
  47. // rewrite: (path) => path.replace(/^\/api/, ''),
  48. },
  49. },
  50. },
  51. })