vite.config.ts 2.0 KB

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