2
0

vite.config.ts 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import { defineConfig } from 'vite'
  2. import react from '@vitejs/plugin-react-swc'
  3. import tailwindcss from '@tailwindcss/vite'
  4. import { progressTrackingPlugin } from 'vite-progress-tracking-plugin';
  5. import iframeCommunicationPlugin from 'vite-plugin-iframe-communicator';
  6. // https://vite.dev/config/
  7. export default defineConfig({
  8. plugins: [
  9. react({
  10. tsDecorators: true,
  11. }),
  12. tailwindcss(),
  13. progressTrackingPlugin(),
  14. iframeCommunicationPlugin({
  15. hostOrigin: '*', // 可信的主页面源
  16. })
  17. ],
  18. server: {
  19. allowedHosts:true,
  20. proxy: {
  21. '/mini': {
  22. target: 'http://localhost:10086',
  23. changeOrigin: true,
  24. },
  25. '/mini-ws': {
  26. target: 'ws://localhost:10086/ws',
  27. changeOrigin: true,
  28. rewrite: path => path.replace(/^\/mini-ws/, ''),
  29. ws: true
  30. },
  31. '/talent-mini': {
  32. target: 'http://localhost:10087',
  33. changeOrigin: true,
  34. },
  35. '/talent-mini-ws': {
  36. target: 'ws://localhost:10087/ws',
  37. changeOrigin: true,
  38. rewrite: path => path.replace(/^\/talent-mini-ws/, ''),
  39. ws: true
  40. },
  41. },
  42. watch: {
  43. // 忽略指定目录,使用 glob 模式
  44. ignored: [
  45. '**/node_modules/**', // Vite 默认已忽略 node_modules
  46. '**/dist/**', // 忽略 dist 目录
  47. 'coverage/**',
  48. 'playwright-report/**',
  49. 'test-results/**',
  50. 'tests/**',
  51. ]
  52. }
  53. },
  54. // 配置 @ 别名
  55. resolve: {
  56. alias: {
  57. '@': '/src',
  58. },
  59. },
  60. // 构建配置
  61. build: {
  62. // 对于SSR,我们不需要默认的index.html入口
  63. // 为客户端构建指定JS入口文件
  64. rollupOptions: {
  65. input: {
  66. // 这里指定你的客户端入口JS文件
  67. main: 'src/client/index.tsx',
  68. styles: 'src/style.css',
  69. },
  70. },
  71. },
  72. })