vite.config.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. import AutoImport from 'unplugin-auto-import/vite'
  7. import Components from 'unplugin-vue-components/vite'
  8. import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
  9. // https://vitejs.dev/config/
  10. export default defineConfig({
  11. server:{
  12. cors: true,
  13. proxy: {
  14. // 代理所有 /api 的请求,该求情将被代理到 target 中
  15. '/api': {
  16. // 代理请求之后的请求地址(你的真实接口地址)
  17. target: 'https://datamidplat.zjw.sh.cegn.cn:2011/data-business-prod/',
  18. //target: 'http://localhost:9250',
  19. secure: false,
  20. ws: true,
  21. // 跨域
  22. // configure: (proxy) => {
  23. // proxy.on('proxyReq', function (proxyReq) {
  24. // proxyReq.removeHeader('referer')
  25. // proxyReq.removeHeader('origin')
  26. // proxyReq.setHeader('host','10.90.11.49:2002')
  27. // })
  28. // },
  29. changeOrigin: true,
  30. rewrite: (path) => path.replace(/^\/api/, '')
  31. }
  32. },
  33. },
  34. // https:true,
  35. build: {
  36. sourcemap: true
  37. },
  38. css:{
  39. devSourcemap:true
  40. },
  41. devtool: 'source-map',
  42. plugins: [
  43. vue(),
  44. AutoImport({
  45. resolvers: [ElementPlusResolver()],
  46. }),
  47. Components({
  48. resolvers: [ElementPlusResolver()],
  49. }),
  50. ],
  51. base:'./',
  52. publicDir: resolve('static'),
  53. resolve: {
  54. alias: {
  55. '@': fileURLToPath(new URL('./src', import.meta.url))
  56. }
  57. }
  58. })