Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: fix build config #655

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions packages/studio-website/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import react from '@vitejs/plugin-react';
import { viteSingleFile } from 'vite-plugin-singlefile';
import dotenv from 'dotenv';
import wasm from 'vite-plugin-wasm';
import path from 'path';

// 获取传递的参数
const args = process.argv.slice(2);
Expand All @@ -17,10 +18,21 @@ args.forEach(arg => {
const { mode } = params;
const isSingle = mode === 'single' && process.env.NODE_ENV === 'production';

console.log('params', params, args);

const plugins = isSingle ? [react(), viteSingleFile(), wasm()] : [react(), wasm()];
console.log('params', params, args);

const plugins = isSingle ? [react(),
// viteSingleFile(),
wasm()] : [react(), wasm()];
const rollupOptions = isSingle ? {
output: {
globals: {}, // 如果有外部依赖,这里定义全局变量映射
inlineDynamicImports: true, // 内联动态导入,防止拆分
entryFileNames: `[name].portal.js`, // 不带hash的入口文件名
chunkFileNames: `[name].portal.js`, // 不带hash的块文件名
assetFileNames: `[name].portal.[ext]`, // 不带hash的资源文件名
}
}:{}
const { parsed } = dotenv.configDotenv();

const { COORDINATOR_URL } = parsed || {};
Expand Down Expand Up @@ -51,10 +63,16 @@ export default defineConfig({
},
build: {
// minify: false,
// outDir: './dist',
// rollupOptions: {
// external: ['node:os', 'fsevents'], // 要排除的模块
// },
minify: false,
outDir: './dist',
rollupOptions: {
external: ['node:os', 'fsevents'], // 要排除的模块
},
...rollupOptions
}
},
plugins,
optimizeDeps: {
Expand Down
Loading