vite.config.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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: mode != 'production'
  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. build: {
  58. sourcemap: true,
  59. minify: true
  60. }
  61. }
  62. })