| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- /*
- * @Description:
- * @Version: 1.668
- * @Autor: 地虎降天龙
- * @Date: 2023-10-16 10:53:09
- * @LastEditors: 地虎降天龙
- * @LastEditTime: 2025-12-31 11:44:50
- */
- // import { resolve } from 'path';
- import { join, dirname } from 'path'
- import { fileURLToPath } from 'url'
- import { defineBuildConfig } from '@fesjs/fes'
- import { templateCompilerOptions } from '@tresjs/core'
- // eslint-disable-next-line import/no-unresolved
- import UnoCSS from 'unocss/vite'
- // eslint-disable-next-line import/no-extraneous-dependencies
- import glsl from 'vite-plugin-glsl'
- import federation from '@originjs/vite-plugin-federation'
- import cesiumStatic from './src/common/cesiumStaticPlugin.js'
- import localGisStatic from './src/common/localGisStaticPlugin.js'
- import { vendoredPluginLibAliases } from './src/common/vendoredPluginLibAliases.js'
- const __filename = fileURLToPath(import.meta.url);
- const __dirname = dirname(__filename);
- const timeStamp = new Date().getTime()
- const combinedIsCustomElement = (tag) => tag.startsWith('iconify-icon') || templateCompilerOptions.template.compilerOptions.isCustomElement(tag)
- export default defineBuildConfig({
- mountElementId: 'tvt-app',
- title: 'TvT.js',
- publicPath: './', // './' 若在线部署用于生产环境 且 是使用qiankun微前端时,需要配置base为主应用地址 https://cos.icegl.cn/qiankun/tvt/
- access: {
- roles: {
- admin: ['*'],
- manager: ['/'],
- },
- },
- layout: {
- navigation: null,
- },
- enums: {
- status: [
- ['0', '无效的'],
- ['1', '有效的'],
- ],
- },
- qiankun: {
- micro: {
- useDevMode: true,
- },
- },
- //add by 地虎降天龙
- viteVuePlugin: {
- template: {
- compilerOptions: {
- isCustomElement: (tag) => combinedIsCustomElement(tag),
- },
- },
- },
- viteOption: {
- plugins: [
- UnoCSS({
- /* options */
- }),
- glsl({
- warnDuplicatedImports: false, // 禁用重复导入警告
- }),
- federation({
- name: 'tvt-host',
- remotes: {
- home: {
- // 必须默认引用一个 不然会报错:ReferenceError: __rf_placeholder__shareScope is not defined
- external: `Promise.resolve('https://dcser.icegl.cn/assets/remoteEntry.js')`,
- externalType: "promise"
- }
- },
- shared: {
- vue: {},
- three: { version: '0.180.0' },
- // "@tresjs/cientos": { version: '5.2.0' },
- // "@tresjs/core": { version: '5.2.0' },
- // three: { import: false, generate: false }
- }
- // 票27:cesium 不进 shared —— 远程不需要它,且体积大、CESIUM_BASE_URL 是进程级单例。
- }),
- // 票27:把 cesium 预构建静态资源接到 <base>/cesium/(dev 中间件 + build 拷贝)。
- cesiumStatic(),
- // 票21:把本机/甲方的 GIS 目录(DEM、影像切片)挂成静态路径,目录由 .env.local 的
- // COCKPIT_GIS_MOUNTS 给;没配就什么也不挂,别的机器照常跑。
- localGisStatic()
- ],
- build: {
- target: 'esnext', // 或者 'es2020' 以支持 BigInt
- chunkSizeWarningLimit: 1000, // 单位为KB
- rollupOptions: {
- output: {
- minifyInternalExports: false,
- manualChunks: {
- three: ['three'],
- '3d-tiles-renderer': ['3d-tiles-renderer'],
- cesium: ['cesium'], // 票27:引擎单独分包
- },
- // manualChunks (id) {
- // // 自定义拆分策略,例如将特定的第三方库拆分为单独的 chunk
- // if (id.includes('node_modules')) {
- // const texts = id.toString().split('node_modules/')[1].split('/')[0]
- // // if (texts) {
- // // console.log(id.toString(), texts)
- // // }
- // return texts
- // }
- // },
- format: 'es',
- chunkFileNames: `js/[name].[hash]${timeStamp}.js`,
- entryFileNames: `js/[name].[hash]${timeStamp}.js`,
- assetFileNames: `[ext]/[name].[hash]${timeStamp}.[ext]`,
- name: 'TvT.js',
- },
- },
- sourcemap: false,
- minify: 'terser',
- },
- // 全局 css 注册
- css: {
- preprocessorOptions: {
- scss: {
- // javascriptEnabled: true,
- // additionalData: `@import "src/plugins/goView/lib/scss/style.scss";`,
- additionalData: (content, filename) => {
- if (filename.includes('src/plugins/goView') || filename.includes('src/plugins/zone3Deditor')) {
- return `@import "src/plugins/goView/lib/scss/style.scss";\n${content}`
- }
- return content
- }
- },
- },
- },
- server: {
- headers: {
- 'Access-Control-Allow-Origin': '*',
- },
- host: '0.0.0.0',
- // 票26:面板与 DSH 的原子写临时文件在 Windows 上都会让 chokidar 抛 EBUSY 击穿 dev server。
- // `**/.scratch/**` → issue tracker 面板保存单据时的 .tmpdir 原子写
- // `**/.dsh-*` → DSH 每次编辑文件时在项目根生成的 .dsh-edit-review.json.<pid>.<guid>.tmpdir
- // `**/*.tmpdir/**` → 票27 实测:同一类原子写临时目录这次落在**源码目录旁**
- // (src/modules/cockpit/components/.MapCanvas.vue.<pid>.<guid>.tmpdir),
- // 前两条都盖不住,pre.dev.one 首次启动被击穿。按模式排除,别只堵已知的那一个路径。
- // Vite 内部默认 ignore(node_modules/.git/cacheDir 等)与此合并而非覆盖,见 vite resolveChokidarOptions。
- watch: {
- // 目录本身与目录内容要分别盖住:chokidar 对目录条目的匹配和对其内容的匹配是两条判断,
- // 只写 `**/*.tmpdir/**` 时那个目录本身仍会被进入,读它时照样 EBUSY。
- ignored: ['**/.scratch/**', '**/.dsh-*', '**/*.tmpdir', '**/*.tmpdir/**'],
- },
- proxy: {
- '/resource.cos': {
- target: 'https://opensource.cdn.icegl.cn',
- changeOrigin: true,
- rewrite: (path) => path.replace(/^\/resource.cos/, ''),
- },
- // 天地图本地代理
- '/tianditu.map': {
- target: 'https://t0.tianditu.gov.cn/',
- changeOrigin: true,
- headers: {
- Origin: 'opensource.icegl.cn',
- Referer: 'http://opensource.icegl.cn',
- },
- rewrite: (path) => path.replace(/^\/tianditu.map/, ''),
- }
- },
- },
- },
- alias: {
- // 插件自带的依赖副本(src/plugins/<插件>/lib/<包>)指回插件内部:
- // useThreeGeospatial 用的 @takram/three-3d-tiles-support 等包没有发布到 npm,
- // 不映射的话 yarn build 会直接在这些 import 上失败。
- ...vendoredPluginLibAliases(join(__dirname, './src/plugins'), join(__dirname, './node_modules')),
- PLS: join(__dirname, './src/plugins'),
- },
- // { find: 'pls', replacement: resolve(__dirname, './src/plugins') },
- // { '@': join(__dirname, '/src') }
- })
|