mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-19 06:30:10 +08:00
refactor(electron.vite.config.ts): streamline external dependencies and improve build configuration (#9835)
- Removed hardcoded external dependencies and replaced them with dynamic extraction from package.json. - Cleaned up the configuration for better maintainability and flexibility in managing dependencies.
This commit is contained in:
parent
fdee510c8c
commit
9f7d2be463
@ -4,6 +4,8 @@ import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
|
|||||||
import { resolve } from 'path'
|
import { resolve } from 'path'
|
||||||
import { visualizer } from 'rollup-plugin-visualizer'
|
import { visualizer } from 'rollup-plugin-visualizer'
|
||||||
|
|
||||||
|
import pkg from './package.json' assert { type: 'json' }
|
||||||
|
|
||||||
const visualizerPlugin = (type: 'renderer' | 'main') => {
|
const visualizerPlugin = (type: 'renderer' | 'main') => {
|
||||||
return process.env[`VISUALIZER_${type.toUpperCase()}`] ? [visualizer({ open: true })] : []
|
return process.env[`VISUALIZER_${type.toUpperCase()}`] ? [visualizer({ open: true })] : []
|
||||||
}
|
}
|
||||||
@ -26,20 +28,7 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
external: [
|
external: ['bufferutil', 'utf-8-validate', 'electron', ...Object.keys(pkg.dependencies)],
|
||||||
'@libsql/client',
|
|
||||||
'bufferutil',
|
|
||||||
'utf-8-validate',
|
|
||||||
'jsdom',
|
|
||||||
'electron',
|
|
||||||
'graceful-fs',
|
|
||||||
'selection-hook',
|
|
||||||
'@napi-rs/system-ocr',
|
|
||||||
'@strongtz/win32-arm64-msvc',
|
|
||||||
'os-proxy-config',
|
|
||||||
'sharp',
|
|
||||||
'turndown'
|
|
||||||
],
|
|
||||||
output: {
|
output: {
|
||||||
manualChunks: undefined, // 彻底禁用代码分割 - 返回 null 强制单文件打包
|
manualChunks: undefined, // 彻底禁用代码分割 - 返回 null 强制单文件打包
|
||||||
inlineDynamicImports: true // 内联所有动态导入,这是关键配置
|
inlineDynamicImports: true // 内联所有动态导入,这是关键配置
|
||||||
|
|||||||
@ -75,7 +75,6 @@
|
|||||||
"@napi-rs/system-ocr": "patch:@napi-rs/system-ocr@npm%3A1.0.2#~/.yarn/patches/@napi-rs-system-ocr-npm-1.0.2-59e7a78e8b.patch",
|
"@napi-rs/system-ocr": "patch:@napi-rs/system-ocr@npm%3A1.0.2#~/.yarn/patches/@napi-rs-system-ocr-npm-1.0.2-59e7a78e8b.patch",
|
||||||
"@strongtz/win32-arm64-msvc": "^0.4.7",
|
"@strongtz/win32-arm64-msvc": "^0.4.7",
|
||||||
"graceful-fs": "^4.2.11",
|
"graceful-fs": "^4.2.11",
|
||||||
"htmlparser2": "^10.0.0",
|
|
||||||
"jsdom": "26.1.0",
|
"jsdom": "26.1.0",
|
||||||
"node-stream-zip": "^1.15.0",
|
"node-stream-zip": "^1.15.0",
|
||||||
"officeparser": "^4.2.0",
|
"officeparser": "^4.2.0",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user