Is it possible to install Reactrb and Opal via NPM and Webpack?

152 Views Asked by At

Is it possible to have NPM/Webpack package Opal and Reactrb? I would simply like to install Reactrb like this:

NPM install Opal --save

NPM install Reactrb --save

And then require as necessary.

Then ```webpack`` to package Reactrb and Opal corelib/stdlib files into a small number of JS files (and not the nearly 200 files they come in today)

In my case, I am using Rails so Sprockets is doing the work to compile Ruby to JS and that is working fine with the opal-rails Gem. What I am trying to past is that this approach results in over 200 files being downloaded each time there is a page refresh (during development). Sprockets will of course compile all that into one JS file when I precompile assets, but I am looking for an approach to do that via Webpack so I can develop with far fewer JS files for Opal and Reactrb and just my own components being downloaded on each page refresh.

It would be great to see a community certified approach to this.

Thanks!

1

There are 1 best solutions below

0
On

try to use this github repositories:

opal-webpack

opalrb-loader

In examples folder you can see how to integrate opal and webpack. Also i think you can add 'Reactrb' gem to Gemfile and require it in ruby file. The integration with Rails available but i think need write additional gem.

and check: https://github.com/fkchang/getting-started-reactrb-webpack