vite.config.js 943B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. server: {
  8. proxy: {
  9. '/api/': {
  10. // 要代理的地址
  11. target: 'http://jgz.njyunzhi.com',
  12. // 配置了这个可以从 http 代理到 https
  13. // 依赖 origin 的功能可能需要这个,比如 cookie
  14. changeOrigin: true,
  15. },
  16. }
  17. },
  18. plugins: [
  19. react(),
  20. vitePluginImp({
  21. libList: [
  22. {
  23. libName: 'antd',
  24. style: (name) => `antd/es/${name}/style`,
  25. }
  26. ]
  27. })
  28. ],
  29. resolve: {
  30. alias: [
  31. { find: '@', replacement: path.resolve(__dirname, 'src') },
  32. ],
  33. },
  34. css: {
  35. preprocessorOptions: {
  36. less: {
  37. // modifyVars: { 'primary-color': '#13c2c2' },
  38. javascriptEnabled: true,
  39. },
  40. },
  41. },
  42. })