vite.config.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import { defineConfig, loadEnv } from 'vite'
  2. import react from '@vitejs/plugin-react-swc'
  3. import {AntdResolve, createStyleImportPlugin} from "vite-plugin-style-import";
  4. // eslint-disable-next-line @typescript-eslint/ban-ts-comment
  5. // @ts-ignore
  6. import qiankun from 'vite-plugin-qiankun'
  7. import mdx from '@mdx-js/rollup'
  8. import * as path from 'path'
  9. export default defineConfig(({command, mode})=>{
  10. console.log('command,mode', command,mode)
  11. const env = loadEnv(mode, process.cwd(),'')
  12. console.log('env', env.VITE_BASE_API)
  13. return {
  14. plugins: [
  15. mdx({
  16. format: 'detect',
  17. include: ["**/*.md",'**/*.mdx']
  18. }),
  19. react(),
  20. createStyleImportPlugin({
  21. resolves: [AntdResolve()]
  22. }),
  23. qiankun('nginx-ui',{
  24. useDevMode: true
  25. }),
  26. ],
  27. css: {
  28. preprocessorOptions: {
  29. less: {
  30. javascriptEnabled: true
  31. }
  32. }
  33. },
  34. resolve:{
  35. alias: {
  36. '@': path.resolve(__dirname,'./src'),
  37. 'docs': path.resolve(__dirname,'./docs')
  38. }
  39. },
  40. assetsInclude: ["**/*.md"],
  41. server:{
  42. proxy: {
  43. ...(mode === 'desktop')? {
  44. "/api":{
  45. target: 'http://127.0.0.1:38080',
  46. rewrite: path => path.replace(/^\/api/,"")
  47. }
  48. } : {
  49. "/api":{
  50. target: 'http://10.10.0.1:8080',
  51. // target: 'http://127.0.0.1:8080',
  52. rewrite: path => path.replace(/^\/api/,"")
  53. }
  54. }
  55. }
  56. }
  57. }
  58. })