vite.config_20230410132145.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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: 8008,
  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. },
  37. resolve: {
  38. alias: {
  39. '@': fileURLToPath(new URL('./src', import.meta.url)),
  40. '@common': common
  41. }
  42. }
  43. };
  44. });