ShakaCode | ShakaCode Blog | Rails On Maui Blog | Rails | ReactJs | JavaScript | Webpack | Productivity |

Sprockets with React_on_Rails webpacker not working


#1

I have installed the react_on_rails gem in my project which required updating my ruby version. I fixed all the upgrade errors but my assets are not being compiled correctly. I suspect this is due to webpacker conflicting with the assets pipeline. For example, jQuery is not recognized in the console, and my css is not correct. Is it possible to use react_on_Rails webpacker for the react files, and stick with the asset pipeline for compiling existing files? And if so, any idea how to fix the problem? I had errors telling me to add the following lines to my application.rb file after upgrading ruby versions and not sure if thats the problem or not, I am not sure why I need these.
config.assets.precompile += [‘ie.css’]
config.assets.precompile += [‘foundation3/normalize.css’]
config.assets.precompile += [‘foundation3/foundation.css’]
config.assets.precompile += [‘ie8.css’]
config.assets.precompile += [‘rem.min.js’]


#2
  1. React on Rails v8+ does not use sprockets
  2. React on Rails needs to use webpacker_lite.
  3. In terms of “things not there”, you need to look into the chrome dev console as well as the page source.

If you want personalized help on this, please consider our Coaching Plan.