Skip to content

Commit d8f76b3

Browse files
authored
Merge pull request #655 from GraphScope/fix-build
feat: fix build config
2 parents 5c19fe3 + 3369c30 commit d8f76b3

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

packages/studio-website/vite.config.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import react from '@vitejs/plugin-react';
33
import { viteSingleFile } from 'vite-plugin-singlefile';
44
import dotenv from 'dotenv';
55
import wasm from 'vite-plugin-wasm';
6+
import path from 'path';
67

78
// 获取传递的参数
89
const args = process.argv.slice(2);
@@ -17,10 +18,21 @@ args.forEach(arg => {
1718
const { mode } = params;
1819
const 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+
}:{}
2436
const { parsed } = dotenv.configDotenv();
2537

2638
const { 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

Comments
 (0)