123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { defineConfig } from 'vite'
  2. import path from "path"
  3. import react from '@vitejs/plugin-react'
  4. import vitePluginImp from 'vite-plugin-imp'
  5. // https://vitejs.dev/config/
  6. export default defineConfig({
  7. base: '/jgz/',
  8. server: {
  9. host: '0.0.0.0',
  10. proxy: {
  11. '/api/': {
  12. // 要代理的地址
  13. target: 'http://127.0.0.1:8087',
  14. // 配置了这个可以从 http 代理到 https
  15. // 依赖 origin 的功能可能需要这个,比如 cookie
  16. changeOrigin: true,
  17. },
  18. }
  19. },
  20. plugins: [
  21. react(),
  22. vitePluginImp({
  23. libList: [
  24. {
  25. libName: 'antd',
  26. style: (name) => `antd/es/${name}/style`,
  27. }
  28. ]
  29. })
  30. ],
  31. resolve: {
  32. alias: [
  33. { find: '@', replacement: path.resolve(__dirname, 'src') },
  34. ],
  35. },
  36. css: {
  37. preprocessorOptions: {
  38. less: {
  39. // modifyVars: { 'primary-color': '#13c2c2' },
  40. javascriptEnabled: true,
  41. },
  42. },
  43. },
  44. })