优选联盟机构推广后台管理系统

vite.config.js 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { defineConfig } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import path from 'path'
  4. // https://vitejs.dev/config/
  5. export default defineConfig({
  6. base: './',
  7. plugins: [vue()],
  8. resolve: {
  9. alias: {
  10. '@': path.resolve(__dirname, 'src'),
  11. '@styles': path.resolve(__dirname, 'src/styles')
  12. }
  13. },
  14. css: {
  15. preprocessorOptions: {
  16. scss: {
  17. additionalData: ''
  18. }
  19. }
  20. },
  21. server: {
  22. port: 12345,
  23. strictPort: false,
  24. host: true,
  25. cors: true,
  26. proxy: {
  27. '^/api': {
  28. target: 'https://shop.wenxingshuju.com',
  29. changeOrigin: true,
  30. secure: false,
  31. rewrite: (path) => path,
  32. configure: (proxy, options) => {
  33. // 添加必要的响应头
  34. proxy.on('proxyRes', (proxyRes, req, res) => {
  35. proxyRes.headers['Access-Control-Allow-Origin'] = '*'
  36. proxyRes.headers['Access-Control-Allow-Methods'] = 'GET,POST,PUT,DELETE,OPTIONS'
  37. proxyRes.headers['Access-Control-Allow-Headers'] = 'Content-Type,Authorization'
  38. })
  39. }
  40. }
  41. }
  42. },
  43. logLevel: 'info',
  44. clearScreen: false,
  45. build: {
  46. sourcemap: true
  47. }
  48. })