.fes.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*
  2. * @Description:
  3. * @Version: 1.668
  4. * @Autor: 地虎降天龙
  5. * @Date: 2023-10-16 10:53:09
  6. * @LastEditors: 地虎降天龙
  7. * @LastEditTime: 2025-12-31 11:44:50
  8. */
  9. // import { resolve } from 'path';
  10. import { join, dirname } from 'path'
  11. import { fileURLToPath } from 'url'
  12. import { defineBuildConfig } from '@fesjs/fes'
  13. import { templateCompilerOptions } from '@tresjs/core'
  14. // eslint-disable-next-line import/no-unresolved
  15. import UnoCSS from 'unocss/vite'
  16. // eslint-disable-next-line import/no-extraneous-dependencies
  17. import glsl from 'vite-plugin-glsl'
  18. import federation from '@originjs/vite-plugin-federation'
  19. const __filename = fileURLToPath(import.meta.url);
  20. const __dirname = dirname(__filename);
  21. const timeStamp = new Date().getTime()
  22. const combinedIsCustomElement = (tag) => tag.startsWith('iconify-icon') || templateCompilerOptions.template.compilerOptions.isCustomElement(tag)
  23. export default defineBuildConfig({
  24. mountElementId: 'tvt-app',
  25. title: 'TvT.js',
  26. publicPath: './', // './' 若在线部署用于生产环境 且 是使用qiankun微前端时,需要配置base为主应用地址 https://cos.icegl.cn/qiankun/tvt/
  27. access: {
  28. roles: {
  29. admin: ['*'],
  30. manager: ['/'],
  31. },
  32. },
  33. layout: {
  34. navigation: null,
  35. },
  36. enums: {
  37. status: [
  38. ['0', '无效的'],
  39. ['1', '有效的'],
  40. ],
  41. },
  42. qiankun: {
  43. micro: {
  44. useDevMode: true,
  45. },
  46. },
  47. //add by 地虎降天龙
  48. viteVuePlugin: {
  49. template: {
  50. compilerOptions: {
  51. isCustomElement: (tag) => combinedIsCustomElement(tag),
  52. },
  53. },
  54. },
  55. viteOption: {
  56. plugins: [
  57. UnoCSS({
  58. /* options */
  59. }),
  60. glsl({
  61. warnDuplicatedImports: false, // 禁用重复导入警告
  62. }),
  63. federation({
  64. name: 'tvt-host',
  65. remotes: {
  66. home: {
  67. // 必须默认引用一个 不然会报错:ReferenceError: __rf_placeholder__shareScope is not defined
  68. external: `Promise.resolve('https://dcser.icegl.cn/assets/remoteEntry.js')`,
  69. externalType: "promise"
  70. }
  71. },
  72. shared: {
  73. vue: {},
  74. three: { version: '0.180.0' },
  75. // "@tresjs/cientos": { version: '5.2.0' },
  76. // "@tresjs/core": { version: '5.2.0' },
  77. // three: { import: false, generate: false }
  78. }
  79. })
  80. ],
  81. build: {
  82. target: 'esnext', // 或者 'es2020' 以支持 BigInt
  83. chunkSizeWarningLimit: 1000, // 单位为KB
  84. rollupOptions: {
  85. output: {
  86. minifyInternalExports: false,
  87. manualChunks: {
  88. three: ['three'],
  89. '3d-tiles-renderer': ['3d-tiles-renderer'],
  90. },
  91. // manualChunks (id) {
  92. // // 自定义拆分策略,例如将特定的第三方库拆分为单独的 chunk
  93. // if (id.includes('node_modules')) {
  94. // const texts = id.toString().split('node_modules/')[1].split('/')[0]
  95. // // if (texts) {
  96. // // console.log(id.toString(), texts)
  97. // // }
  98. // return texts
  99. // }
  100. // },
  101. format: 'es',
  102. chunkFileNames: `js/[name].[hash]${timeStamp}.js`,
  103. entryFileNames: `js/[name].[hash]${timeStamp}.js`,
  104. assetFileNames: `[ext]/[name].[hash]${timeStamp}.[ext]`,
  105. name: 'TvT.js',
  106. },
  107. },
  108. sourcemap: false,
  109. minify: 'terser',
  110. },
  111. // 全局 css 注册
  112. css: {
  113. preprocessorOptions: {
  114. scss: {
  115. // javascriptEnabled: true,
  116. // additionalData: `@import "src/plugins/goView/lib/scss/style.scss";`,
  117. additionalData: (content, filename) => {
  118. if (filename.includes('src/plugins/goView') || filename.includes('src/plugins/zone3Deditor')) {
  119. return `@import "src/plugins/goView/lib/scss/style.scss";\n${content}`
  120. }
  121. return content
  122. }
  123. },
  124. },
  125. },
  126. server: {
  127. headers: {
  128. 'Access-Control-Allow-Origin': '*',
  129. },
  130. host: '0.0.0.0',
  131. // 票26:面板与 DSH 的原子写临时文件在 Windows 上都会让 chokidar 抛 EBUSY 击穿 dev server。
  132. // `**/.scratch/**` → issue tracker 面板保存单据时的 .tmpdir 原子写
  133. // `**/.dsh-*` → DSH 每次编辑文件时在项目根生成的 .dsh-edit-review.json.<pid>.<guid>.tmpdir
  134. // Vite 内部默认 ignore(node_modules/.git/cacheDir 等)与此合并而非覆盖,见 vite resolveChokidarOptions。
  135. watch: {
  136. ignored: ['**/.scratch/**', '**/.dsh-*'],
  137. },
  138. proxy: {
  139. '/resource.cos': {
  140. target: 'https://opensource.cdn.icegl.cn',
  141. changeOrigin: true,
  142. rewrite: (path) => path.replace(/^\/resource.cos/, ''),
  143. },
  144. // 天地图本地代理
  145. '/tianditu.map': {
  146. target: 'https://t0.tianditu.gov.cn/',
  147. changeOrigin: true,
  148. headers: {
  149. Origin: 'opensource.icegl.cn',
  150. Referer: 'http://opensource.icegl.cn',
  151. },
  152. rewrite: (path) => path.replace(/^\/tianditu.map/, ''),
  153. }
  154. },
  155. },
  156. },
  157. alias: {
  158. PLS: join(__dirname, './src/plugins'),
  159. },
  160. // { find: 'pls', replacement: resolve(__dirname, './src/plugins') },
  161. // { '@': join(__dirname, '/src') }
  162. })