This project shows how to build an application with both Rails and Vite.js in the same repo.
It does not use the Rails gem Webpacker to manage JavaScript and CSS. It's fully delegated to Vite.js.
During development, we don't need to build assets, so we are using the Vite.js server on port 3001.
In production, we need to build assets in the public folder with yarn build command.
To prevent conflicts with the public folder, I changed the Vite.js root option in the vite.config.js file.
Development environment requirements :
$ git clone https://github.com/guillaumebriday/rails-vitejs.git && cd rails-vitejsTo run the backend
$ bundle
$ bundle exec rails sTo run the Frontend:
$ yarn
$ yarn devOpen http://localhost:3000 in your browser.
Do not hesitate to contribute to the project by adapting or adding features ! Bug reports or pull requests are welcome.
This project is released under the MIT license.