vite.config.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. },
  33. // 配置 @ 别名
  34. resolve: {
  35. alias: {
  36. '@': '/src',
  37. },
  38. },
  39. // 构建配置
  40. build: {
  41. // 对于SSR,我们不需要默认的index.html入口
  42. // 为客户端构建指定JS入口文件
  43. rollupOptions: {
  44. input: {
  45. // 这里指定你的客户端入口JS文件
  46. main: 'src/client/index.tsx',
  47. styles: 'src/style.css',
  48. },
  49. },
  50. },
  51. })