vite.config.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import { fileURLToPath, URL } from 'node:url';
  2. import { defineConfig, loadEnv } from 'vite';
  3. import vue from '@vitejs/plugin-vue';
  4. // vant
  5. import Components from 'unplugin-vue-components/vite';
  6. import { VantResolver } from 'unplugin-vue-components/resolvers';
  7. const path = require('path');
  8. const common = path.resolve(__dirname, '../common');
  9. export default defineConfig(({ mode }) => {
  10. const env = loadEnv(mode, __dirname);
  11. return {
  12. // 静态路径
  13. base: env.VITE_BASE_URL,
  14. // 打包名称
  15. build: {
  16. outDir: env.VITE_OUT_DIR
  17. },
  18. plugins: [
  19. vue(),
  20. Components({
  21. resolvers: [VantResolver()]
  22. })
  23. ],
  24. server: {
  25. port: 8007,
  26. proxy: {
  27. '/files': {
  28. target: 'http://basic.waityou24.cn'
  29. },
  30. '/jcyjdtglpt/v1/api': {
  31. target: 'http://192.168.1.113:13010',
  32. changeOrigin: true,
  33. ws: false
  34. }
  35. },
  36. fs: { strict: false }
  37. },
  38. resolve: {
  39. alias: {
  40. '@': fileURLToPath(new URL('./src', import.meta.url)),
  41. '@common': common
  42. }
  43. }
  44. };
  45. });