diff --git a/core/core-frontend/.env.distributed b/core/core-frontend/.env.distributed new file mode 100644 index 0000000000..8a93b1c1c6 --- /dev/null +++ b/core/core-frontend/.env.distributed @@ -0,0 +1,3 @@ +# 接口前缀 +VITE_API_BASEPATH="./de2api" +VITE_VERSION="0.0.0" diff --git a/core/core-frontend/config/distributed.ts b/core/core-frontend/config/distributed.ts new file mode 100644 index 0000000000..54c51667de --- /dev/null +++ b/core/core-frontend/config/distributed.ts @@ -0,0 +1,32 @@ +import pkg from '../package.json' +import viteCompression from 'vite-plugin-compression' + +export default { + plugins: [ + viteCompression({ + // gzip静态资源压缩配置 + verbose: true, // 是否在控制台输出压缩结果 + disable: false, // 是否禁用压缩 + threshold: 10240, // 启用压缩的文件大小限制 + algorithm: 'gzip', // 采用的压缩算法 + ext: '.gz' // 生成的压缩包后缀 + }) + ], + build: { + rollupOptions: { + external: id => /de-xpack/.test(id), + output: { + // 用于命名代码拆分时创建的共享块的输出命名 + chunkFileNames: `assets/chunk/[name]-${pkg.version}-${pkg.name}.js`, + assetFileNames: `assets/[ext]/[name]-${pkg.version}-${pkg.name}.[ext]`, + entryFileNames: `js/[name]-${pkg.version}-${pkg.name}.js`, + manualChunks(id: string) { + if (id.includes('node_modules')) { + return id.toString().split('node_modules/')[1].split('/')[0].toString() + } + } + } + }, + sourcemap: false + } +} diff --git a/core/core-frontend/package.json b/core/core-frontend/package.json index 82d27937e7..24f9fd20d2 100644 --- a/core/core-frontend/package.json +++ b/core/core-frontend/package.json @@ -7,6 +7,7 @@ "build:flush": "cd ./flushbonading && rimraf ./demo.html && npm i && node ./index.js", "ts:check": "vue-tsc --noEmit", "build:base": "NODE_OPTIONS=--max_old_space_size=4096 vite build --mode base && npm run build:flush", + "build:distributed": "NODE_OPTIONS=--max_old_space_size=4096 vite build --mode distributed && npm run build:flush", "build:lib": "vite build --mode lib", "lint": "eslint . --ext .vue,.js,.ts,.jsx,.tsx --fix", "lint:stylelint": "stylelint --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/", diff --git a/core/core-frontend/pom.xml b/core/core-frontend/pom.xml index bf1024abfc..d56196db6f 100644 --- a/core/core-frontend/pom.xml +++ b/core/core-frontend/pom.xml @@ -74,7 +74,7 @@ npm - run build:base + run build:distributed diff --git a/core/core-frontend/vite.config.ts b/core/core-frontend/vite.config.ts index 39fd954a91..e482977f41 100644 --- a/core/core-frontend/vite.config.ts +++ b/core/core-frontend/vite.config.ts @@ -1,5 +1,6 @@ import common from './config/common'; import base from './config/base'; +import distributed from './config/distributed'; import dev from './config/dev'; import lib from './config/lib'; import pages from './config/pages'; @@ -13,6 +14,9 @@ export default defineConfig(({mode}) => { if (mode === 'lib') { return mergeConfig(common , lib) } + if (mode === 'distributed') { + return mergeConfig(common, mergeConfig(distributed, pages)) + } return mergeConfig(common, mergeConfig(base, pages)) }) diff --git a/de-xpack b/de-xpack index 68a6c1ae72..44b16d7cfc 160000 --- a/de-xpack +++ b/de-xpack @@ -1 +1 @@ -Subproject commit 68a6c1ae726d0523843666edf1490c3857492235 +Subproject commit 44b16d7cfc1d05167aeecad51767da723af45abd