Skip to content

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

Closed
@xhc-code

Description

Pre-flight checklist

  • I have read the contribution documentation for this project.
  • 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'
           }
         ]
       }
     }
   ],
};

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions