You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The size of the exe packaged by forge is ridiculously large. I think this is caused by not using vite build to build the dist directory. Also, all dependencies of dependent libraries are packaged, without distinguishing between used and unused ones. #3420
I agree to follow the code of conduct that this project uses.
I have searched the issue tracker for a bug that matches the one I want to file, without success.
Electron Forge version
7.1
Electron version
27.1
Operating system
win10
Last known working Electron Forge version
No response
Expected behavior
The dist directory built by forge using vite
Actual behavior
Hello, I used electron-forge to package the vite practice project into an exe. The dist directory built through npm run build is only 108kb. But the asar file built through electron-forge reaches 18mb. Is this because I haven't configured it? Or is this how the packager works, without using the dist directory built by vite.
The size of the exe packaged by forge is ridiculously large. I think this is caused by not using vite build to build the dist directory. Also, all dependencies of dependent libraries are packaged, without distinguishing between used and unused ones.
Steps to reproduce
none
Additional information
My project structure:
root
electron: Place main.js and preload.js of electron
src: Place the files of vue and main.js (vue).
index.html file
...
forge.config.js content
module.exports = {
packagerConfig: {
asar: true,
productName: "APp",
},
rebuildConfig: {},
makers: [
{
name: '@electron-forge/maker-squirrel',
config: {},
},
{
name: '@electron-forge/maker-zip',
platforms: ['darwin'],
},
{
name: '@electron-forge/maker-deb',
config: {},
},
{
name: '@electron-forge/maker-rpm',
config: {},
},
],
plugins: [
{
name: '@electron-forge/plugin-auto-unpack-natives',
config: {},
},
{
name: '@electron-forge/plugin-vite',
config: {
// `build` can specify multiple entry builds, which can be
// Main process, Preload scripts, Worker process, etc.
build: [
{
// `entry` is an alias for `build.lib.entry`
// in the corresponding file of `config`.
entry: 'main.js',
config: 'vite.main.config.js'
},
{
entry: 'preload.js',
config: 'vite.preload.config.js'
}
],
renderer: [
{
name: 'main_window',
config: 'vite.renderer.config.js'
}
]
}
}
],
};
Hi, I had a similar issue, in my case, there were unnecessary files in the project that were being added to the .exe, once I told forge to exclude them the .exe size decreased significantly .
All I had to do was add the ignore option to packagerConfig in forge.config.js
It takes a regex object or array of regex objects, in my case it looks like this:
Activity
michalakis commentedon Nov 23, 2023
Hi, I had a similar issue, in my case, there were unnecessary files in the project that were being added to the .exe, once I told forge to exclude them the .exe size decreased significantly .
All I had to do was add the ignore option to packagerConfig in forge.config.js
It takes a regex object or array of regex objects, in my case it looks like this:
of course you are using vite, I dont know if that means you have to place this somewhere else
Viiprogrammer commentedon Dec 15, 2023
Check my answer in the related question - #3423 (comment)
caoxiemeihao commentedon Jan 17, 2024
Fixed in #3336