vite.config.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. },
  32. watch: {
  33. // 忽略指定目录,使用 glob 模式
  34. ignored: [
  35. '**/node_modules/**', // Vite 默认已忽略 node_modules
  36. '**/dist/**', // 忽略 dist 目录
  37. 'coverage/**',
  38. 'playwright-report/**',
  39. 'test-results/**',
  40. 'tests/**',
  41. ]
  42. }
  43. },
  44. // 配置 @ 别名
  45. resolve: {
  46. alias: {
  47. '@': '/src',
  48. },
  49. },
  50. // 构建配置
  51. build: {
  52. // 对于SSR,我们不需要默认的index.html入口
  53. // 为客户端构建指定JS入口文件
  54. rollupOptions: {
  55. input: {
  56. // 这里指定你的客户端入口JS文件
  57. main: 'src/client/index.tsx',
  58. styles: 'src/style.css',
  59. },
  60. },
  61. },
  62. })