我制作了一个简单的桌面应用程序,使用React(与Vite一起)和ElectronJS。我只检查了React应用程序(CSS、js和html)的最终文件的捆绑包大小,不出所料,它非常非常低。
然后我使用Electron构建器进行打包,选择为可移植到Windows,但与React捆绑包的大小相比,最终应用程序的大小非常大,为168MB,我不知道该怎么做才能减少它。我一直在搜索Electron和Electron构建器文档,但没有得到答案,有人能帮我吗?
我试着优化React应用程序的性能,但没有什么能改变Electron构建器生成的最终可执行文件的大小
package.json配置:
{
"name": "venedolar-app",
"private": true,
"version": "1.0.0",
"description": "Monitor application that displays the currencies of Venezuela up to date",
"type": "module",
"main": "dist/electron.cjs",
"scripts": {
"dev": "vite",
"start": "electron .",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview",
"pack": "electron-builder --dir",
"dist": "electron-builder"
},
"author": "Gabriel Trujillo",
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.4.2",
"@fortawesome/free-solid-svg-icons": "^6.4.2",
"@fortawesome/react-fontawesome": "^0.2.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"sass": "^1.69.5"
},
"devDependencies": {
"@types/react": "^18.2.15",
"@types/react-dom": "^18.2.7",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"@vitejs/plugin-react-swc": "^3.3.2",
"electron": "^27.0.3",
"electron-builder": "^24.6.4",
"eslint": "^8.45.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"typescript": "^5.0.2",
"vite": "^4.4.5"
},
"build": {
"appId": "com.venedolar.app",
"productName": "Venedolar",
"copyright": "Copyright @ 2023 Gabriel Trujillo, Diego Peña",
"win": {
"icon": "dist/icon2.ico",
"target": [
"portable"
],
"artifactName": "Venedolar1.0_portable.exe"
},
"directories": {
"output": "build",
"buildResources": "dist"
},
"files": [
"dist/**/*"
]
}
}