升级vite8

This commit is contained in:
JEECG 2026-07-12 10:39:29 +08:00
parent 1b7ed30b9e
commit 3f4626fb4e

View File

@ -33,33 +33,23 @@ export default async ({ command, mode }: ConfigEnv): Promise<UserConfig> => {
const serverOptions: Recordable = {} const serverOptions: Recordable = {}
// ----- [begin] JEECG ----- // JEECG origin
const {VITE_GLOB_QIANKUN_MICRO_APP_NAME, VITE_GLOB_QIANKUN_MICRO_APP_ENTRY} = viteEnv; const {VITE_GLOB_QIANKUN_MICRO_APP_NAME, VITE_GLOB_QIANKUN_MICRO_APP_ENTRY} = viteEnv;
const isQiankunMicro = VITE_GLOB_QIANKUN_MICRO_APP_NAME != null && VITE_GLOB_QIANKUN_MICRO_APP_NAME !== ''; const isQiankunMicro = VITE_GLOB_QIANKUN_MICRO_APP_NAME != null && VITE_GLOB_QIANKUN_MICRO_APP_NAME !== '';
if (isQiankunMicro && !isBuild) { if (isQiankunMicro && !isBuild) {
serverOptions.cors = true; serverOptions.cors = true;
serverOptions.origin = VITE_GLOB_QIANKUN_MICRO_APP_ENTRY!.split('/').slice(0, 3).join('/'); serverOptions.origin = VITE_GLOB_QIANKUN_MICRO_APP_ENTRY!.split('/').slice(0, 3).join('/');
} }
// ----- [end] JEECG -----
console.log('[init] Start Port: ', VITE_PORT); console.log('[init] Start Port: ', VITE_PORT);
console.debug('[init] Vite Proxy Config: ', VITE_PROXY); console.debug('[init] Vite Proxy Config: ', VITE_PROXY);
return { return {
base: isQiankunMicro ? VITE_GLOB_QIANKUN_MICRO_APP_ENTRY : VITE_PUBLIC_PATH, base: isQiankunMicro ? VITE_GLOB_QIANKUN_MICRO_APP_ENTRY : VITE_PUBLIC_PATH,
root, root,
resolve: { resolve: {
alias: [ alias: [
// @logicflow/vue-node-registry 1.1.13 npm src/ package.json // @rys-fe/vite-plugin-theme vite 8 RegExp
// main/module lib/es/vite 6 esbuild srcrolldown
// import src/index.ts
{
find: /^@logicflow\/vue-node-registry$/,
replacement: pathResolve('node_modules/@logicflow/vue-node-registry/src/index.ts'),
},
// @rys-fe/vite-plugin-theme vite 8
// RegExp vite resolve.extensions
{ {
find: /^@rys-fe\/vite-plugin-theme\/es\/client$/, find: /^@rys-fe\/vite-plugin-theme\/es\/client$/,
replacement: pathResolve('build/vite/plugin/theme-plugin/client/client'), replacement: pathResolve('build/vite/plugin/theme-plugin/client/client'),
@ -103,12 +93,9 @@ export default async ({ command, mode }: ConfigEnv): Promise<UserConfig> => {
// @ts-ignore // @ts-ignore
https: false, https: false,
port: VITE_PORT, port: VITE_PORT,
// Load proxy configuration from .env
proxy: createProxy(VITE_PROXY), proxy: createProxy(VITE_PROXY),
// server
...serverOptions, ...serverOptions,
// update-begin--author:liaozhiyang---date:20260306---for:QQYUN-14801vite访 // update-begin--author:liaozhiyang---date:20260306---for:QQYUN-14801访
//
warmup: { warmup: {
clientFiles: [ clientFiles: [
'./src/main.ts', './src/main.ts',
@ -117,7 +104,7 @@ export default async ({ command, mode }: ConfigEnv): Promise<UserConfig> => {
'src/layouts/default/index.vue' 'src/layouts/default/index.vue'
], ],
}, },
// update-end--author:liaozhiyang---date:20260306---for:QQYUN-14801vite访 // update-end--author:liaozhiyang---date:20260306---for:QQYUN-14801访
}, },
build: { build: {
minify: 'esbuild', minify: 'esbuild',
@ -125,22 +112,24 @@ export default async ({ command, mode }: ConfigEnv): Promise<UserConfig> => {
cssTarget: 'chrome80', cssTarget: 'chrome80',
outDir: OUTPUT_DIR, outDir: OUTPUT_DIR,
rollupOptions: { rollupOptions: {
//
// treeshake: false,
output: { output: {
chunkFileNames: 'js/[name]-[hash].js', // chunkFileNames: 'js/[name]-[hash].js',
entryFileNames: 'js/[name]-[hash].js', // entryFileNames: 'js/[name]-[hash].js',
// manualChunks ()
// update-begin--author:copilot---date:20260711---for:vite8rolldownmanualChunks // update-begin--author:copilot---date:20260711---for:vite8rolldownmanualChunks
// id.includes('node_modules') + split('node_modules/') chunk
manualChunks(id: string) { manualChunks(id: string) {
const normalizedId = id.replace(/\\/g, '/'); const normalizedId = id.replace(/\\/g, '/');
if (normalizedId.includes('/node_modules/vue/') || normalizedId.includes('/node_modules/vue-router/')) { if (!normalizedId.includes('node_modules/')) {
// vue vue-router return;
return 'vue-vendor';
}
if (normalizedId.includes('/node_modules/emoji-mart-vue-fast/')) {
return 'emoji-mart-vue-fast';
} }
const segments = normalizedId.split('node_modules/').pop()!.split('/');
const pkgName = segments[0].startsWith('@') ? `${segments[0]}/${segments[1]}` : segments[0];
const packageToChunk: Record<string, string> = {
vue: 'vue-vendor',
'vue-router': 'vue-vendor',
'emoji-mart-vue-fast': 'emoji-mart-vue-fast',
};
return packageToChunk[pkgName];
}, },
// update-end--author:copilot---date:20260711---for:vite8rolldownmanualChunks // update-end--author:copilot---date:20260711---for:vite8rolldownmanualChunks
}, },