-
Notifications
You must be signed in to change notification settings - Fork 74
Description
I created a brand new Rails app using the Rails 8 app generator to see how easily Inertia could be added to an existing and recent project using the Inertia's Rails generator.
To my surprise, it just didn't work out of the box. (and I still haven't been able to make it work)
π οΈ Setup
Im sticking to defaults, I just created a Rails app with rails new jurisflow --database=postgresql --javascript=esbuild --css=tailwind --skip-jbuilder --skip-action-mailbox --skip-action-text --skip-hotwire --skip-test
. Nothing else and nothing more.
β First issue: incorrect Procfile.dev
was generated
Procfile.dev
was generatedI ran the Inertia Rails generator install tool: bin/rails generate inertia:install --framework=react --typescript --vite
Output of the command
~Check that your vite.json configuration file is available in the load path:~
No such file or directory @ rb_sysopen - /Users/andy/AndyDev/jurisflow/config/vite.json
Installing Inertia's Rails adapter
Could not find a Vite configuration files (`config/vite.json` & `vite.config.{ts,js,mjs,cjs,mts,cts}`).
run bundle add vite_rails from "."
Vite Rails gem successfully installed
run bundle exec vite install from "."
Vite Rails successfully installed
Adding TypeScript support
run yarn add @types/react @types/react-dom typescript --silent from "."
Copying adding scripts to package.json
run npm pkg set scripts.check="tsc -p tsconfig.app.json && tsc -p tsconfig.node.json" from "."
Would you like to install Tailwind CSS? (y/n) y
Installing Tailwind CSS
run yarn add tailwindcss @tailwindcss/vite @tailwindcss/forms @tailwindcss/typography --silent from "."
warning Pattern ["tailwindcss@^4.1.3"] is trying to unpack in the same destination "/Users/andy/Library/Caches/Yarn/v6/npm-tailwindcss-4.1.3-f5a6b4451295c06e213013697f7193be1630fa46-integrity/node_modules/tailwindcss" as pattern ["[email protected]","[email protected]","[email protected]"]. This could result in non-deterministic behavior, skipping.
prepend vite.config.mts
insert vite.config.mts
create app/frontend/entrypoints/application.css
Adding Tailwind CSS to the application layout
insert app/views/layouts/application.html.erb
Adding Inertia's Rails adapter initializer
create config/initializers/inertia_rails.rb
Installing Inertia npm packages
run yarn add @inertiajs/react@latest @vitejs/plugin-react react react-dom --silent from "."
warning Workspaces can only be enabled in private projects.
warning Workspaces can only be enabled in private projects.
warning Workspaces can only be enabled in private projects.
warning Workspaces can only be enabled in private projects.
Adding Vite plugin for react
insert vite.config.mts
prepend vite.config.mts
Copying inertia.ts entrypoint
create app/frontend/entrypoints/inertia.ts
Adding inertia.ts script tag to the application layout
insert app/views/layouts/application.html.erb
Adding Vite React Refresh tag to the application layout
insert app/views/layouts/application.html.erb
gsub app/views/layouts/application.html.erb
Copying example Inertia controller
create app/controllers/inertia_example_controller.rb
Adding a route for the example Inertia controller
route get 'inertia-example', to: 'inertia_example#index'
Copying page assets
create app/frontend/pages/InertiaExample.module.css
create app/frontend/assets/react.svg
create app/frontend/assets/inertia.svg
create app/frontend/assets/vite_ruby.svg
create app/frontend/pages/InertiaExample.tsx
create tsconfig.json
create tsconfig.app.json
create tsconfig.node.json
create app/frontend/vite-env.d.ts
Copying bin/dev
conflict bin/dev
Overwrite /Users/andy/AndyDev/jurisflow/bin/dev? (enter "h" for help) [Ynaqdhm] Y
force bin/dev
To my surprise, after trying to boot up the Rails app through bin/dev
multiple times and failing due to "service already using the same port", I checked Procfile.dev
and this is what I got:
web: env RUBY_DEBUG_OPEN=true bin/rails server
js: yarn build --watch
css: yarn build:css --watch
vite: bin/vite dev
web: bin/rails s
It looks like the conflict and overwrite of bin/dev
after I typed Y
in the console didn't merge well Procfile.dev
and ended up with a duplicated web
service (?). Just a guess.
Edit:
it's actuallyvite_rails
' fault: ElMassimo/vite_ruby#541
β Second issue: inertia-example
route can't load all assets
After fixing the Procfile.dev
, I was able to run the app π.
However, navigating to http://localhost:3000/inertia-example
resulted in a blank page.
In the browser dev tools, I saw some requests failed:
- inertia.ts
- application.css
- tailwindcss

edit:
I just noticed vite-dev connection is logging an error each 1s:
