how install Svelte framewoek with Rails 6+ and Sprocket (no webpack)

212 Views Asked by At

I have a Rails 6 app and I want use Svelte on client side only

I have nodeJS, NPM and Yarn installed.

Now, how can I install Svelte to this app without webpack, only using sprocket ?

1

There are 1 best solutions below

3
On

You could use jsbundling by adding the gem and then you have your choice of esbuild, rollup, or webpacker.

This article summarizes it well: https://anonoz.github.io/tech/2021/12/11/rails-tailwindcss-svelte.html

Another resource for jsbundling: https://github.com/rails/jsbundling-rails

The other option would be start with Rails 7 and declare esbuild from the beginning. Then you can just use Yarn to add Svelte to the project.