vite.config.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import { fileURLToPath, URL } from 'node:url'
  2. import vue from '@vitejs/plugin-vue'
  3. import vueJsx from '@vitejs/plugin-vue-jsx'
  4. import UnoCSS from 'unocss/vite'
  5. import AutoImport from 'unplugin-auto-import/vite'
  6. import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers'
  7. import Components from 'unplugin-vue-components/vite'
  8. import DefineOptions from 'unplugin-vue-define-options/vite'
  9. import { defineConfig, loadEnv } from 'vite'
  10. import vitePluginBuildId from 'vite-plugin-build-id'
  11. import svgLoader from 'vite-svg-loader'
  12. // https://vitejs.dev/config/
  13. export default defineConfig(({ mode }) => {
  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. UnoCSS(),
  38. Components({
  39. resolvers: [AntDesignVueResolver({ importStyle: false })],
  40. directoryAsNamespace: true,
  41. }),
  42. AutoImport({
  43. imports: [
  44. 'vue',
  45. 'vue-router',
  46. 'pinia',
  47. {
  48. '@/gettext': [
  49. '$gettext',
  50. '$pgettext',
  51. '$ngettext',
  52. '$npgettext',
  53. ],
  54. },
  55. ],
  56. vueTemplate: true,
  57. eslintrc: {
  58. enabled: true,
  59. filepath: '.eslint-auto-import.mjs',
  60. },
  61. }),
  62. DefineOptions(),
  63. ],
  64. css: {
  65. preprocessorOptions: {
  66. less: {
  67. modifyVars: {
  68. 'border-radius-base': '5px',
  69. },
  70. javascriptEnabled: true,
  71. },
  72. },
  73. },
  74. server: {
  75. port: Number.parseInt(env.VITE_PORT) || 3002,
  76. proxy: {
  77. '/api': {
  78. target: env.VITE_PROXY_TARGET || 'http://localhost:9000',
  79. changeOrigin: true,
  80. secure: false,
  81. ws: true,
  82. },
  83. },
  84. },
  85. build: {
  86. chunkSizeWarningLimit: 1000,
  87. },
  88. }
  89. })