Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: capistrano deployment docs correction for vite v5 #454

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tenkiller
Copy link

@tenkiller tenkiller commented Apr 15, 2024

Description 馃摉

When using Vite v5 and above, Capistrano is not aware that the location of the asset manifest files has moved, and fails on deployment with Rails assets manifest file not found.

Background 馃摐

When using Vite v5 and above, asset manifest files are output to a vite/.vite/ subdirectory, by default. Meaning that the manifest.json and manifest-assets.json files that used to reside under public/vite/ now reside under public/vite/.vite/.

The Fix 馃敤

Update documentation to reflect that there is a difference between the Capistrano configuration when using Vite v4 and Vite v5. The fix when using Vite v5 and above is to set the Capistrano :assets_manifests option. The path(s) need to be relative or absolute.

@rgioia
Copy link

rgioia commented May 3, 2024

@tenkiller
Thanks for the update! It started working as you mentioned. Now, the issue I'm facing is that when the Skipping asset precompile, no asset diff found, the deploy fails with the following error: Rails Assets manifest file not found.

Could there be a path conflict with Sprockets searching for the manifest?

set :assets_prefix, 'vite'
set :assets_manifests, ["public/#{fetch(:assets_prefix)}/.vite/manifest*.*"]
ls      /releases/xxxx/public/vite/manifest*
ls      ls: cannot access /releases/xxxx/public/vite/manifest*
ls      10 : No such file or directory

ls      /releases/xxxx/public/vite/.sprockets-manifest*
ls      ls: cannot access /releases/xxxx/public/vite/.sprockets-manifest*'
ls      No such file or directory

@tenkiller
Copy link
Author

@rgioia Good point. I had considered including the path for the Rails Asset Pipeline (i.e. sprockets), but we weren't getting any errors on deployment for our setup, so I overlooked it.

By setting :assets_manifests, it overrides the default, which is

[
  "/path/to/release_path/public/#{fetch(:assets_prefix)}/.sprockets-manifest*", 
  "/path/to/release_path/public/#{fetch(:assets_prefix)}/manifest*.*"
]

But, we don't want to add this back in as given because assets_prefix is set to vite. The default prefix for the Rails Asset Pipeline is assets. So, I think, this should remedy it?

set :assets_manifests, [
  "public/assets/.sprockets-manifest*",
  "public/assets/manifest*.*",
  "public/#{fetch(:assets_prefix)}/.vite/manifest*.*"
]

@rgioia
Copy link

rgioia commented May 15, 2024

@tenkiller Thank you! I managed to do what I needed; I successfully switched from Webpacker to Vite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants