vite.config.ts 967 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { defineConfig } from 'vite';
  2. import uni from '@dcloudio/vite-plugin-uni';
  3. import path from 'path';
  4. function resolve(dir) {
  5. return path.join(__dirname, dir);
  6. }
  7. // https://vitejs.dev/config/
  8. export default defineConfig(({ mode }) => {
  9. const isProd = mode === 'production';
  10. const commonConfig = {
  11. optimizeDeps: {
  12. include: [
  13. '@tencentcloud/tuiroom-engine-wx',
  14. '@tencentcloud/chat',
  15. '@tencentcloud/tui-core',
  16. ],
  17. },
  18. plugins: [uni()],
  19. resolve: {
  20. alias: {
  21. '@': resolve('src'),
  22. '@TUIRoom': resolve('src/roomkit/TUIRoom'),
  23. },
  24. },
  25. build: {
  26. rollupOptions: {
  27. external: [
  28. '@tencentcloud/tuiroom-engine-wx',
  29. '@tencentcloud/chat',
  30. '@tencentcloud/tui-core',
  31. ],
  32. },
  33. },
  34. };
  35. const devConfig = {
  36. ...commonConfig,
  37. };
  38. const prodConfig = {
  39. ...commonConfig,
  40. };
  41. return isProd ? prodConfig : devConfig;
  42. });