A Vite plugin that provides convention-over-configuration integration for Ruby projects, primarily used with Rails, Hanami, or plain Ruby via the vite_ruby gem. Current stable version is 5.2.1. It is updated regularly alongside the vite_ruby ecosystem. Unlike generic Vite setups, it auto-discovers entry points, handles asset paths, and bridges Vite's HMR with Ruby development servers. Ships TypeScript types. Requires Vite >=5.0.0.
npm install vite-plugin-rubyVerified import paths — ran on the pinned version, not inferred.
Basic setup of vite-plugin-ruby in vite.config.ts. Instantiates the plugin without options, relying on convention-based defaults.
Ensure your config/vite.json has a 'source_code_dir' and 'entry_points' defined, or pass them in the plugin options.
Upgrade to Node.js 18 or later.
Set custom paths in vite.json under 'source_code_dir' and 'entry_points'.
Follow the setup guide of vite_ruby to add the ViteRuby middleware in your Rails config.
Run npm install vite-plugin-ruby or yarn add vite-plugin-ruby.
Change to: import ViteRuby from 'vite-plugin-ruby'
Ensure you import the default and call it as a function: import ViteRuby from 'vite-plugin-ruby'; ViteRuby()