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
The following discussion is from PR: #3178. In order to facilitate the discussion and make it easier for other community members to participate, I have created this issue to track this problem.
erikian:
Looks like Vite's default cache directory is node_modules/.vite, so we end up packaging that folder along with the project dependencies when building the project. Do you think it would be possible to use cacheDir: './.vite' as the default in the Vite configs, either here or maybe directly in the Vite plugin?
caoxiemeihao:
The directory node_modules/.vite is esbuildPre-Bundling cache dir, it's only work vite serve phase and ignored vite build phase by default. (@electron-forge/plugin-vite just run vite build)
Even if it is used in the vite build phase, it is rebuild by Vite into the dist folder.
erikian:
The directory node_modules/.vite is esbuild Pre-Bundling cache dir
That's why we don't need it in node_modules when the app is packaged - the contents of this folder are not necessary for the app to run, but it's being included anyway 😅
In my case, I tested the template with a hello world React app (just electron-squirrel-startup, react and react-dom as dependencies), and my out/<project_name>/resources/app/node_modules/.vite folder was about 2.5 MB. No big deal, but I'm thinking it might become more of a problem for larger apps with multiple dependencies, so it might be worth addressing that somehow (maybe just deleting the folder from node_modules before packaging or using the packageAfterCopy hook could do the trick here).
That being said, I have zero experience with Vite and I don't how large this folder can get - if it never exceeds a couple megabytes, it might not be worth the hassle.
In my case, node_modules is not included in the built app directory, even if we need some runtime dependencies to build with node_modules, node_modules/.vite is not included in the final app directory.
Of course, this Demo uses electron-builder, I have not had time to replace it with forge, I will try to replace it with forge later.
erikian:
Looks like Vite's default cache directory is
node_modules/.vite
, so we end up packaging that folder along with the project dependencies when building the project. Do you think it would be possible to usecacheDir: './.vite'
as the default in the Vite configs, either here or maybe directly in the Vite plugin?caoxiemeihao:
The directory
node_modules/.vite
isesbuild
Pre-Bundling cache dir, it's only workvite serve
phase and ignoredvite build
phase by default. (@electron-forge/plugin-vite
just runvite build
)Even if it is used in the
vite build
phase, it is rebuild by Vite into thedist
folder.erikian:
That's why we don't need it in
node_modules
when the app is packaged - the contents of this folder are not necessary for the app to run, but it's being included anyway 😅In my case, I tested the template with a hello world React app (just
electron-squirrel-startup
,react
andreact-dom
as dependencies), and myout/<project_name>/resources/app/node_modules/.vite
folder was about 2.5 MB. No big deal, but I'm thinking it might become more of a problem for larger apps with multiple dependencies, so it might be worth addressing that somehow (maybe just deleting the folder fromnode_modules
before packaging or using thepackageAfterCopy
hook could do the trick here).That being said, I have zero experience with Vite and I don't how large this folder can get - if it never exceeds a couple megabytes, it might not be worth the hassle.
Originally posted in #3178 (comment)
The text was updated successfully, but these errors were encountered: