修复打包错误
This commit is contained in:
@@ -156,7 +156,6 @@ pub fn write_claude_config(config: &ClaudeConfig) -> Result<(), String> {
|
||||
}
|
||||
|
||||
/// 备份当前配置
|
||||
#[allow(dead_code)]
|
||||
pub fn backup_claude_config() -> Result<(), String> {
|
||||
let config_path = get_claude_config_path()?;
|
||||
let backup_path = get_config_backup_path()?;
|
||||
|
||||
172
vite.config.ts
172
vite.config.ts
@@ -7,123 +7,63 @@ const host = process.env.TAURI_DEV_HOST;
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig(async () => ({
|
||||
plugins: [react(), tailwindcss()],
|
||||
plugins: [react(), tailwindcss()],
|
||||
|
||||
// Path resolution
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": fileURLToPath(new URL("./src", import.meta.url)),
|
||||
},
|
||||
},
|
||||
|
||||
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
|
||||
//
|
||||
// 1. prevent vite from obscuring rust errors
|
||||
clearScreen: false,
|
||||
// 2. tauri expects a fixed port, fail if that port is not available
|
||||
server: {
|
||||
port: 1420,
|
||||
strictPort: true,
|
||||
host: host || false,
|
||||
hmr: host
|
||||
? {
|
||||
protocol: "ws",
|
||||
host,
|
||||
port: 1421,
|
||||
}
|
||||
: undefined,
|
||||
watch: {
|
||||
// 3. tell vite to ignore watching `src-tauri`
|
||||
ignored: ["**/src-tauri/**"],
|
||||
},
|
||||
},
|
||||
|
||||
// Build configuration for code splitting
|
||||
build: {
|
||||
// Increase chunk size warning limit to 3000 KB
|
||||
chunkSizeWarningLimit: 3000,
|
||||
|
||||
rollupOptions: {
|
||||
output: {
|
||||
// Manual chunks for better code splitting
|
||||
manualChunks: (id) => {
|
||||
// React core
|
||||
if (id.includes('node_modules/react/') || id.includes('node_modules/react-dom/')) {
|
||||
return 'react-vendor';
|
||||
}
|
||||
|
||||
// Monaco Editor - split into separate chunks
|
||||
if (id.includes('node_modules/monaco-editor/')) {
|
||||
return 'monaco-editor';
|
||||
}
|
||||
if (id.includes('node_modules/@monaco-editor/')) {
|
||||
return 'monaco-react';
|
||||
}
|
||||
|
||||
// Radix UI - split into smaller chunks
|
||||
if (id.includes('node_modules/@radix-ui/')) {
|
||||
if (id.includes('react-dialog') || id.includes('react-dropdown-menu')) {
|
||||
return 'radix-overlay';
|
||||
}
|
||||
if (id.includes('react-select') || id.includes('react-tabs')) {
|
||||
return 'radix-navigation';
|
||||
}
|
||||
return 'radix-base';
|
||||
}
|
||||
|
||||
// Tauri
|
||||
if (id.includes('node_modules/@tauri-apps/')) {
|
||||
return 'tauri';
|
||||
}
|
||||
|
||||
// Charts
|
||||
if (id.includes('node_modules/recharts/')) {
|
||||
return 'recharts';
|
||||
}
|
||||
|
||||
// Framer Motion
|
||||
if (id.includes('node_modules/framer-motion/')) {
|
||||
return 'framer-motion';
|
||||
}
|
||||
|
||||
// Syntax highlighting
|
||||
if (id.includes('node_modules/react-syntax-highlighter/')) {
|
||||
return 'syntax-vendor';
|
||||
}
|
||||
|
||||
// Markdown editor
|
||||
if (id.includes('node_modules/@uiw/react-md-editor/')) {
|
||||
return 'editor-vendor';
|
||||
}
|
||||
|
||||
// DnD Kit
|
||||
if (id.includes('node_modules/@dnd-kit/')) {
|
||||
return 'dnd-kit';
|
||||
}
|
||||
|
||||
// Virtual scrolling
|
||||
if (id.includes('node_modules/@tanstack/react-virtual/')) {
|
||||
return 'virtual';
|
||||
}
|
||||
|
||||
// Utilities
|
||||
if (id.includes('node_modules/date-fns/') ||
|
||||
id.includes('node_modules/clsx/') ||
|
||||
id.includes('node_modules/tailwind-merge/')) {
|
||||
return 'utils';
|
||||
}
|
||||
|
||||
// Lucide icons
|
||||
if (id.includes('node_modules/lucide-react/')) {
|
||||
return 'lucide-icons';
|
||||
}
|
||||
|
||||
// Other large node_modules
|
||||
if (id.includes('node_modules/')) {
|
||||
return 'vendor';
|
||||
}
|
||||
// Path resolution
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": fileURLToPath(new URL("./src", import.meta.url)),
|
||||
},
|
||||
},
|
||||
|
||||
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
|
||||
//
|
||||
// 1. prevent vite from obscuring rust errors
|
||||
clearScreen: false,
|
||||
// 2. tauri expects a fixed port, fail if that port is not available
|
||||
server: {
|
||||
port: 1420,
|
||||
strictPort: true,
|
||||
host: host || false,
|
||||
hmr: host
|
||||
? {
|
||||
protocol: "ws",
|
||||
host,
|
||||
port: 1421,
|
||||
}
|
||||
: undefined,
|
||||
watch: {
|
||||
// 3. tell vite to ignore watching `src-tauri`
|
||||
ignored: ["**/src-tauri/**"],
|
||||
},
|
||||
},
|
||||
|
||||
// Build configuration for code splitting
|
||||
build: {
|
||||
// Increase chunk size warning limit to 3000 KB
|
||||
chunkSizeWarningLimit: 3000,
|
||||
|
||||
rollupOptions: {
|
||||
output: {
|
||||
// Manual chunks for better code splitting
|
||||
manualChunks: {
|
||||
// Vendor chunks
|
||||
'react-vendor': ['react', 'react-dom'],
|
||||
'ui-vendor': ['@radix-ui/react-dialog', '@radix-ui/react-dropdown-menu', '@radix-ui/react-select', '@radix-ui/react-tabs', '@radix-ui/react-tooltip', '@radix-ui/react-switch', '@radix-ui/react-popover'],
|
||||
'editor-vendor': ['@uiw/react-md-editor'],
|
||||
'monaco-editor': ['monaco-editor', '@monaco-editor/react'],
|
||||
'syntax-vendor': ['react-syntax-highlighter'],
|
||||
// Animation and motion
|
||||
'framer-motion': ['framer-motion'],
|
||||
// Tauri and other utilities
|
||||
'tauri': ['@tauri-apps/api', '@tauri-apps/plugin-dialog', '@tauri-apps/plugin-shell', '@tauri-apps/plugin-fs', '@tauri-apps/plugin-clipboard-manager'],
|
||||
'utils': ['date-fns', 'clsx', 'tailwind-merge'],
|
||||
// Charts and visualization
|
||||
'recharts': ['recharts'],
|
||||
// Virtual scrolling
|
||||
'virtual': ['@tanstack/react-virtual'],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}));
|
||||
|
||||
Reference in New Issue
Block a user