Registry / web-framework / vite-plugin-rails

vite-plugin-rails

JSON →
library0.6.0jsnpmunverified

vite-plugin-rails v0.6.0 is a Vite plugin that brings convention over configuration to Rails projects, bundling several commonly needed plugins (Ruby integration, gzip/brotli compression, environment variable exposure, full reload on template changes, Stimulus HMR, and SRI manifest hashing) with zero-config defaults while remaining fully configurable. Unlike the minimal vite-plugin-ruby, this plugin provides an opinionated, batteries-included setup for Rails developers. Released under MIT license, maintained by ElMassimo as part of the vite_ruby ecosystem. Requires Vite >=5.0.0.

npm install vite-plugin-rails
INSTALL
IMPORT
SIG · VITE-PLUGIN-RAILS
V
vite-plugin-rails
web-frameworkjavascriptv0.6.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18223 runs
build_error
glibc
node 18223 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

ViteRails
import ViteRails from 'vite-plugin-rails'
const ViteRails = require('vite-plugin-rails')
Default import; the plugin ships TypeScript types. ESM only; CJS require will cause error at runtime.
type ViteRailsOptions
import type { ViteRailsOptions } from 'vite-plugin-rails'
The package exports a `ViteRailsOptions` interface for configuring the plugin in TypeScript.
default
import ViteRailsPlugin from 'vite-plugin-rails'
import { ViteRailsPlugin } from 'vite-plugin-rails'
The package has a default export; named export `ViteRailsPlugin` does not exist. Use default import.

Registers the plugin with Vite config, showing optional compression, environment variables, full reload paths, and Stimulus HMR configuration.

import { defineConfig } from 'vite'; import ViteRails from 'vite-plugin-rails'; export default defineConfig({ plugins: [ ViteRails({ compress: { gzip: true, brotli: false }, envVars: { RAILS_ENV: process.env.RAILS_ENV ?? 'development' }, fullReload: { additionalPaths: ['app/serializers/**/*'] }, stimulus: { controllersPath: 'app/assets/controllers' } }) ] });
Debug
Known issues
breakingUpgrading from vite-plugin-ruby (without the -rails suffix) requires switching to the new package name and updated API.
fix
Replace import from 'vite-plugin-ruby' to 'vite-plugin-rails'; adjust options to match the new config shape.
affects: >=0.1.0
breakingvite-plugin-rails v0.6.0 requires Vite >=5.0.0; older Vite versions are incompatible.
fix
Update Vite to version 5.0.0 or higher.
affects: >=0.6.0
deprecatedThe plugin may deprecate or remove old option keys; always check the latest configuration options source.
fix
Refer to the latest src/index.ts for valid options.
affects: >=0.5.0
gotchaExternal plugins like rollup-plugin-gzip and vite-plugin-full-reload are bundled by default; do not install them separately or duplicate them in plugins array.
fix
Use plugin options to configure bundled plugins; pass `compress: false` to disable completely.
affects: >=0.1.0
gotchaThe default fullReload paths may trigger unnecessary full page reloads on certain file changes if custom caching is used.
fix
Set `fullReload: { additionalPaths: [] }` or configure to match your exact template patterns.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module 'vite-plugin-rails' or its corresponding type declarations.
Package not installed or missing from node_modules.
fix
Run `npm install vite-plugin-rails --save-dev` (or yarn) and ensure package.json includes it.
Error: [vite] Internal server error: The plugin 'vite-plugin-rails' requires Vite version >=5.0.0. Current version: 4.x
Installed Vite version is too old.
fix
Upgrade Vite to version 5.0.0 or newer.
TypeError: Cannot read properties of undefined (reading 'gzip')
Passed invalid options object (e.g., undefined or malformed).
fix
Ensure options object is properly formatted; for example, set `compress: { gzip: true, brotli: false }`.
UnhandledPromiseRejectionWarning: Error: No manifest.json found.
SRI plugin expects manifest to be generated by Vite build but it's missing.
fix
Ensure build is run with the plugin; check if `vite build` completes and manifest.json is produced.
Dynamic require of 'vite-plugin-rails' is not supported
Using CommonJS require() instead of ESM import.
fix
Switch to `import ViteRails from 'vite-plugin-rails'` and ensure your project uses ESM (type: module in package.json).
Upgrade
Version history
0.6.0latest on npm
Audit
Dependencies
viterequiredRequired plugin peer dependency for Vite build tool.
Agent activity
9 hits · last 30 days
node
8
OpenAI (training)
1
Resources
vite-plugin-rails — npm install vite-plugin-rails · libregistry