vite.config.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import { fileURLToPath, URL } from 'node:url'
  2. import vue from '@vitejs/plugin-vue'
  3. import vueJsx from '@vitejs/plugin-vue-jsx'
  4. import AutoImport from 'unplugin-auto-import/vite'
  5. import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'
  6. import Components from 'unplugin-vue-components/vite'
  7. import DefineOptions from 'unplugin-vue-define-options/vite'
  8. import { defineConfig, loadEnv } from 'vite'
  9. import vitePluginBuildId from 'vite-plugin-build-id'
  10. import svgLoader from 'vite-svg-loader'
  11. // https://vitejs.dev/config/
  12. export default defineConfig(({ mode }) => {
  13. const env = loadEnv(mode, process.cwd(), '')
  14. return {
  15. base: './',
  16. resolve: {
  17. alias: {
  18. '@': fileURLToPath(new URL('./src', import.meta.url)),
  19. },
  20. extensions: [
  21. '.mjs',
  22. '.js',
  23. '.ts',
  24. '.jsx',
  25. '.tsx',
  26. '.json',
  27. '.vue',
  28. '.less',
  29. ],
  30. },
  31. plugins: [
  32. vue(),
  33. vueJsx(),
  34. vitePluginBuildId(),
  35. svgLoader(),
  36. Components({
  37. resolvers: [AntDesignVueResolver({ importStyle: false })],
  38. directoryAsNamespace: true,
  39. }),
  40. AutoImport({
  41. imports: [
  42. 'vue',
  43. 'vue-router',
  44. 'pinia',
  45. {
  46. '@/gettext': [
  47. '$gettext',
  48. '$pgettext',
  49. '$ngettext',
  50. '$npgettext',
  51. ],
  52. },
  53. ],
  54. vueTemplate: true,
  55. }),
  56. DefineOptions(),
  57. ],
  58. css: {
  59. preprocessorOptions: {
  60. less: {
  61. modifyVars: {
  62. 'border-radius-base': '5px',
  63. },
  64. javascriptEnabled: true,
  65. },
  66. },
  67. },
  68. server: {
  69. port: Number.parseInt(env.VITE_PORT) || 3002,
  70. proxy: {
  71. '/api': {
  72. target: env.VITE_PROXY_TARGET || 'http://localhost:9000',
  73. changeOrigin: true,
  74. secure: false,
  75. ws: true,
  76. },
  77. },
  78. },
  79. build: {
  80. chunkSizeWarningLimit: 1000,
  81. },
  82. }
  83. })