vite.config.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * @Description:
  3. * @Version: 1.668
  4. * @Autor: 地虎降天龙
  5. * @Date: 2025-12-26 08:14:02
  6. * @LastEditors: 地虎降天龙
  7. * @LastEditTime: 2026-01-09 09:23:31
  8. */
  9. import { defineConfig } from 'vite'
  10. import vue from '@vitejs/plugin-vue'
  11. import glsl from 'vite-plugin-glsl'
  12. import { templateCompilerOptions } from '@tresjs/core'
  13. import federation from '@originjs/vite-plugin-federation'
  14. import dcsConfig from './src/dcsConfig'
  15. // https://vitejs.dev/config/
  16. const exposeMap = {} as any
  17. dcsConfig.components.forEach((item: any) => {
  18. exposeMap[`./${item.type}`] = item.comFile
  19. })
  20. export default defineConfig(({ command }) => {
  21. return {
  22. // base: './',
  23. plugins: [
  24. vue({
  25. ...templateCompilerOptions,
  26. }),
  27. glsl(),
  28. federation({
  29. name: 'remote-tvt-components',
  30. filename: 'remoteEntry.js',
  31. exposes: {
  32. // 不可以使用多层目录
  33. './config': './src/dcsConfig.js',
  34. ...exposeMap,
  35. },
  36. shared: {
  37. vue: {},
  38. three: { requiredVersion: '0.180.0' },
  39. // "@tresjs/cientos": { requiredVersion: '5.2.1' },
  40. // "@tresjs/core": { requiredVersion: '5.2.1' },
  41. },
  42. }),
  43. ],
  44. build: {
  45. rollupOptions: {
  46. output: {
  47. manualChunks: {
  48. three: ['three'],
  49. '@tresjs/cientos': ['@tresjs/cientos']
  50. },
  51. },
  52. },
  53. },
  54. optimizeDeps: {
  55. exclude: command === 'build' ? ['vue', 'three', '@tresjs/cientos'] : ['vue', 'three']
  56. },
  57. }
  58. })