Open tenkiller opened 4 months ago
@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
@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*.*"
]
@tenkiller Thank you! I managed to do what I needed; I successfully switched from Webpacker to Vite.
I don't use Capistrano myself, but if I understand correctly, the instructions are not complete if the app needs to support sprockets, as public/assets
would not be automatically added to linked_dirs
.
Given that some users still mix sprockets
and vite_rails
, and some with propshaft
it might be better to avoid relying on the internals of capistrano-rails
and its usage of assets_prefix
, and instead instruct the user to configure:
"public/vite"
to linked_dirs
release_path.join("public/vite/.vite/manifest*.*")
to assets_manifests
Happy to accept a PR that removes the example setting assets_prefix
and explains how to append these two values.
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 themanifest.json
andmanifest-assets.json
files that used to reside underpublic/vite/
now reside underpublic/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.