A Vite plugin for integrating Vite into Ruby on Rails applications, currently at stable version 0.2.4. It provides seamless asset pipeline integration with both Propshaft and Sprockets, supports SSR, glob patterns for entry points, and works with jsbundling-rails. Regular releases (approximately monthly) with active maintenance. Key differentiators: lightweight, no gem required in jsbundling mode, automatic entry point discovery, subresource integrity, and test mode isolation. Requires Vite >= 5.0.0 and Node >= 18.
npm install rails-vite-pluginVerified import paths — ran on the pinned version, not inferred.
Configures Vite with the Rails plugin, specifying source directory and entry points.
Use ES module import syntax instead of require().
Check the jsbundling mode documentation; if using jsbundling-rails, ensure you follow the correct setup.
Migrate to jsbundling mode (no gem) or use the gem with updated config.
Upgrade Node.js to version 18 or higher.
Upgrade to v0.2.1 or later.
Change to import statement: import rails from 'rails-vite-plugin'. Ensure your project uses ESM (type: module in package.json) or use dynamic import() if needed.
Use a relative path like './entrypoints/application.js' or ensure sourceDir and entrypoints config are correct.
Ensure you do import rails from 'rails-vite-plugin' and then rails({...}) in plugins array.Install vite: npm install vite --save-dev or yarn add vite --dev.