ElMassimo / vite_ruby

⚡️ Vite.js in Ruby, bringing joy to your JavaScript experience
https://vite-ruby.netlify.app/
MIT License
1.28k stars 117 forks source link

Automatically eager load ViteRuby in Rails context #419

Closed tgwizard closed 9 months ago

tgwizard commented 9 months ago

Description 📖

Ensures the ViteRuby manifest is eager loaded, following the Rails pattern (similarly to https://github.com/tzinfo/tzinfo/commit/c4f177c4808c11aa28f87fb3b452f832342c970c).

In dev, when running a rails console or bin/rails server, the manifest is already loaded (because of the Rails::Server and Rails::Console definition checks). But in some environments (e.g. when booting the server through Puma), those constants aren't defined, but we still want to eagerload the manifest.

The PR is still in draft as I dig into why the constants aren't always defined.