-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support new default manifest location in Vite v5 #420
Comments
Good timing, I have something in the |
Closed in #421. Releasing a new version of |
After update to latest I have to do |
You can configure |
Thanks! I was able to fix this issue by cleaning |
@ElMassimo We just run into an issue while upgrading from Vite 4 to Vite 5. After upgrade and deploy, we ended up with this file structure:
After the application rebooted, it was still loading the old JS assets from public/vite/manifest*. I had to SSH in, remove those old manifest files, restart the application server, then things came right. Is this expected? From what I can see of the commit, it should default to V5 manifest but doesn't appear to be working. |
Hi Kieran! In that case, it would load all four manifest files, unfortunately merging the old ones last since the new location is read first. This problem would only happen when preserving assets from previous deployments (as opposed to when using containers). Flipping the order would potentially avoid this problem during upgrades, but since it's a one-time thing I'm leaning towards documenting it in Troubleshooting instead. |
@ElMassimo You are right that the assets are preserved between deployments, a common practice with Capistrano in order to speed up deployment times. However, I feel that documentation may not be enough in this case. We didn't encounter any issues in development before we rolled out the change, so I imagine most people would not check Troubleshooting until it is already too late. I think merging the old and the new should be considered incorrect behaviour. Perhaps a better approach may be to check the for presence of the manifests under .vite and use only those, otherwise fall back to the old manifests. def known_manifest_paths
manifest_files = [
# NOTE: Generated by Vite when `manifest: true`, which vite-plugin-ruby enables.
'manifest.json',
# NOTE: Path where vite-plugin-ruby outputs the assets manifest file.
'manifest-assets.json',
]
vite5_manifest_paths = manifest_files.map { |path|
build_output_dir.join(".vite/#{path}")
}
vite4_manifest_paths = manifest_files.map { |path|
build_output_dir.join(path)
}
if vite5_manifest_paths.any? { |path| File.exists?(path) }
vite5_manifest_paths
else
vite4_manifest_paths
end
end |
@ElMassimo Here is a PR for the above suggested change. It seems to be working well on our deployments. https://github.com/ElMassimo/vite_ruby/pull/432/files |
Is your feature request related to a problem? Please describe.
Vite changed the default manifest location from
${outDir}/manifest.json
to${outDir}/.vite/manifest.json
in Vite v5.https://vitejs.dev/guide/migration#manifest-files-are-now-generated-in-vite-directory-by-default
After upgrading to Vite v5, ViteRuby fails to find the manifest, leading to errors like:
Describe the solution you'd like
One option would be to change the definition of
ViteRuby::Config#manifest_path
to reference the new v5 location:This would not be backwards compatible with v4, however.
Describe alternatives you've considered
Alternatively,
vite-ruby-plugin
could explicitly configure the desired manifest location to match the v4 convention:Additional context
There are likely other changes needed for full Vite v5 compatibility, but this was the first major one I encountered in my testing.
The text was updated successfully, but these errors were encountered: