vite.config.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import * as path from "path";
  2. const resolve = (dir) => path.resolve(__dirname, dir);
  3. import { fileURLToPath, URL } from 'node:url'
  4. import { defineConfig } from 'vite'
  5. import vue from '@vitejs/plugin-vue'
  6. // https://vitejs.dev/config/
  7. export default defineConfig({
  8. server:{
  9. cors: true,
  10. proxy: {
  11. '/api2': {
  12. // 代理请求之后的请求地址(你的真实接口地址)
  13. target: 'https://cimweb.zjw.sh.cegn.cn:2008',
  14. // target: 'http://10.90.7.241:9443/data-business-prod/',
  15. secure: false,
  16. ws: true,
  17. // 跨域
  18. changeOrigin: true,
  19. rewrite: (path) => path.replace(/^\/api2/, '')
  20. },
  21. // 代理所有 /api 的请求,该求情将被代理到 target 中
  22. '/api': {
  23. // 代理请求之后的请求地址(你的真实接口地址)
  24. target: 'https://cimweb.zjw.sh.cegn.cn:2007/data-business-prod/',
  25. // target: 'http://10.90.7.241:9443/data-business-prod/',
  26. secure: false,
  27. ws: true,
  28. // 跨域
  29. changeOrigin: true,
  30. rewrite: (path) => path.replace(/^\/api/, '')
  31. },
  32. },
  33. },
  34. https:true,
  35. build: {
  36. sourcemap:true,
  37. commonjsOptions: {
  38. include: /node_modules|unit\/map\/CityGis.Bridge.js/,
  39. }
  40. },
  41. css:{
  42. devSourcemap:true
  43. },
  44. devtool: 'source-map',
  45. plugins: [
  46. vue(),
  47. ],
  48. base:'./',
  49. publicDir: resolve('public'),
  50. resolve: {
  51. alias: {
  52. '@': fileURLToPath(new URL('./src', import.meta.url))
  53. }
  54. }
  55. })