vite.config.js 962B

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