Skip to content

Commit

Permalink
docs: update deployment instructions for capistrano in vite v5 (#454)
Browse files Browse the repository at this point in the history
Co-authored-by: Maximo Mussini <maximomussini@gmail.com>
  • Loading branch information
tenkiller and ElMassimo authored Sep 25, 2024
1 parent 7c81ddc commit fc3219c
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions docs/src/guide/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,20 +126,27 @@ If using <kbd>[vite-plugin-rails]</kbd>, assets will be compressed using gzip an

While it was originally designed for sprockets, you can easily configure it for _Vite Ruby_, which means you get automatic removal of expired assets, and manifest backups.

It's necessary to extend [the default configuration](https://github.com/capistrano/rails/blob/d86a8db16281f09d8cfff9ee791297134bce9801/lib/capistrano/tasks/assets.rake#L139)
so that it detects the following files:

- `manifest.json`: generated [by Vite](https://vitejs.dev/config/build-options.html#build-manifest) for entrypoints
- `manifest-assets.json`: generated [by `vite-plugin-ruby`](https://github.com/ElMassimo/vite_ruby/blob/main/vite-plugin-ruby/src/manifest.ts#L26-L29) for other assets

```ruby
# config/deploy.rb

# Must match `ViteRuby.config.public_output_dir`, which by default is 'vite'
set :assets_prefix, 'vite'
```

The [default value](https://github.com/capistrano/rails/blob/d86a8db16281f09d8cfff9ee791297134bce9801/lib/capistrano/tasks/assets.rake#L139) for `:assets_manifests` should already backup both:
- `manifest.json`: generated by Vite for entrypoints
- `manifest-assets.json`: generated by _Vite Ruby_
append :linked_dirs, "public/vite"
append :assets_manifests, "public/vite/.vite/manifest*.*"
```

See <kbd>[capistrano-rails]</kbd> for more information about relevant settings
such as `keep_assets` and `assets_roles`.

:::warning Custom Output Dirs
When customizing `ViteRuby.config.public_output_dir` or `ViteRuby.config.public_dir`
change `"public/vite"` to reflect your configuration.
:::

## Using Heroku

In order to deploy to Heroku, it's necessary to add the [nodejs][nodejs buildpack] and [ruby][ruby buildpack] buildpacks.
Expand Down

0 comments on commit fc3219c

Please sign in to comment.