inertiajs / inertia-rails

The Rails adapter for Inertia.js.
https://inertiajs.com
MIT License
529 stars 43 forks source link

Added support for Vite in installer #95

Closed wJoenn closed 11 months ago

wJoenn commented 1 year ago

I figured it wouldn't take too long so in the end I did a first draft today. I have no idea how to test this in my local environment so it has not been tested, sorry about that. If you deem it necessary feel free to give me a hint on the procedure and I'll do that

The idea is simple, we check if vite is installed and we store that boolean in a @vite_installed? variable. We then use that variable to render paths accordingly

The vite_source_code_dir method is used to read the config/vite.json file and grab path to the sourceDir there in case some users have changed that path in their config. It also verifies whether the path includes a closing "/" or not and adds it it's not the case. Again that is to unsure that it wouldn't conflict with different user's config

I created an instances variables instead of methods for @vite_installed? and @vite_source_code_dir because I wanted to avoid reading the file or executing rails vite:verify_install multiple times.

Closes #85

wJoenn commented 1 year ago

I noticed the installer is still using old inertia packages instead of the ones introduce with Inertia 1.0

I just went through the process of setting up a project for Rails 7 with Vue 3, typescript 5, pinia, eslint, vite 4 and inertia 1 manually so I have a fairly good idea of what needs to be done. I could try to update the generator if you want