@@ -3,6 +3,7 @@ import react from '@vitejs/plugin-react';
33import { viteSingleFile } from 'vite-plugin-singlefile' ;
44import dotenv from 'dotenv' ;
55import wasm from 'vite-plugin-wasm' ;
6+ import path from 'path' ;
67
78// 获取传递的参数
89const args = process . argv . slice ( 2 ) ;
@@ -17,10 +18,21 @@ args.forEach(arg => {
1718const { mode } = params ;
1819const isSingle = mode === 'single' && process . env . NODE_ENV === 'production' ;
1920
20- console . log ( 'params' , params , args ) ;
2121
22- const plugins = isSingle ? [ react ( ) , viteSingleFile ( ) , wasm ( ) ] : [ react ( ) , wasm ( ) ] ;
22+ console . log ( 'params' , params , args ) ;
2323
24+ const plugins = isSingle ? [ react ( ) ,
25+ // viteSingleFile(),
26+ wasm ( ) ] : [ react ( ) , wasm ( ) ] ;
27+ const rollupOptions = isSingle ? {
28+ output : {
29+ globals : { } , // 如果有外部依赖,这里定义全局变量映射
30+ inlineDynamicImports : true , // 内联动态导入,防止拆分
31+ entryFileNames : `[name].portal.js` , // 不带hash的入口文件名
32+ chunkFileNames : `[name].portal.js` , // 不带hash的块文件名
33+ assetFileNames : `[name].portal.[ext]` , // 不带hash的资源文件名
34+ }
35+ } :{ }
2436const { parsed } = dotenv . configDotenv ( ) ;
2537
2638const { COORDINATOR_URL } = parsed || { } ;
@@ -51,10 +63,16 @@ export default defineConfig({
5163 } ,
5264 build : {
5365 // minify: false,
66+ // outDir: './dist',
67+ // rollupOptions: {
68+ // external: ['node:os', 'fsevents'], // 要排除的模块
69+ // },
70+ minify : false ,
5471 outDir : './dist' ,
5572 rollupOptions : {
5673 external : [ 'node:os' , 'fsevents' ] , // 要排除的模块
57- } ,
74+ ...rollupOptions
75+ }
5876 } ,
5977 plugins,
6078 optimizeDeps : {
0 commit comments