Currently, when packaging the app, all packages that are specified as deps are copied over into the packaged application (and live in the node_modules directory). this is built-in behavior of the vite plugin and as of right now, there is no way to change this (see https://github.com/electron/forge/issues/3570). this results in a rather bloated package size because it essentially copies over a good portion of the node_modules directory into the archive when it's not necessary to do so. We'll need to adjust the vite configuration to account for this (which was originally mostly taken from a template that they provide, with some adjustments based on issues i found):
[ ] update the build.rollupOptions.externals field to make sure that only native modules or builtins (e.g. electron) are not bundled
[ ] patch the vite plugin to disable the "copy over all deps" behavior
[ ] make sure that necessary static assets are included when building the app
Extracted from https://github.com/digidem/comapeo-desktop/pull/18. That PR introduces changes that generally work fine in development, but when building the archive we run into some issues.
Currently, when packaging the app, all packages that are specified as deps are copied over into the packaged application (and live in the
node_modules
directory). this is built-in behavior of the vite plugin and as of right now, there is no way to change this (see https://github.com/electron/forge/issues/3570). this results in a rather bloated package size because it essentially copies over a good portion of thenode_modules
directory into the archive when it's not necessary to do so. We'll need to adjust the vite configuration to account for this (which was originally mostly taken from a template that they provide, with some adjustments based on issues i found):build.rollupOptions.externals
field to make sure that only native modules or builtins (e.g.electron
) are not bundled