Deploying a Ruby web app using Vite Ruby should be quite straightforward.
vite:build will be executed whenever assets:precompile is run, and the resulting assets will be placed inside the
Rake Tasks ⚙️
In Rails, they are installed automatically, so you can simply use them.
In other apps, you can add them manually in your
require 'vite_ruby' ViteRuby.install_tasks
The following rake tasks are available:
Makes a production bundle with Vite using Rollup behind the scenes.
Called automatically whenever assets:precompile is called.
Remove previous Vite builds.
Called automatically whenever assets:clean is called.
Remove the Vite build output directory.
Called automatically whenever assets:clobber is called.
Provide information on Vite Ruby and related libraries.
You can provide
RACK_ENV=production to simulate a production build locally.
Development Dependencies 🔗
This allows you to skip installation in servers that won't precompile assets, or easily prune them after assets have been precompiled.
Disabling extension of the
During complex migrations, it might be convenient that
vite:build is not run along the
assets:precompile rake task.
You can disable the extension of the
assets:precompile rake task by setting the
VITE_RUBY_SKIP_ASSETS_PRECOMPILE_EXTENSION environment variable to
Compressing Assets 📦
Most CDN and edge service providers will automatically serve compressed assets, which is why Vite does not create compressed copies of each file.
If using vite-plugin-rails, assets will be compressed using gzip and brotli out of the box.
capistrano-rails is a gem that adds Rails-specific tasks to Capistrano, such as support for assets precompilation and migrations.
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.
# config/deploy.rb # Must match `ViteRuby.config.public_output_dir`, which by default is 'vite' set :assets_prefix, 'vite'
The default value for
:assets_manifests should already backup both:
manifest.json: generated by Vite for entrypoints
manifest-assets.json: generated by Vite Ruby
See capistrano-rails for more information about relevant settings such as
Make sure that the ruby buildpack appears last to ensure the proper defaults are applied.
$ heroku buildpacks === pingcrm-vite Buildpack URLs 1. heroku/nodejs 2. heroku/ruby
If you are starting from scratch, you achieve that by running:
heroku buildpacks:set heroku/ruby heroku buildpacks:add --index 1 heroku/nodejs
heroku config:set NPM_CONFIG_INCLUDE='dev' YARN_PRODUCTION=false # or NPM_CONFIG_PRODUCTION=false in versions of npm < 7