Components are not loading in Production Environment
'rails', '5.2.0'
'webpacker', '3.5'
'react-rails', '2.4.4'
"react_ujs": "2.4.4"
I am using react-rails for a part of application written in redux and react, while everything works fine in development, no components seem to load in production, React developer tools shows absolute nothing, there are no errors in browser console nor any in the server console.
I have the lines
config.react.variant = :production
in my Production.rb file.
While I have also tried to manually precompile assets before running the server in production.
This is not one of the simplified and structured issues and I know that this is not the place to ask, but StackOverflow wasn't of any help for me, and I am stuck over this from last 5 hours.
The option config.react.variant = :production won't do anything for you because you're using webpacker and that's for sprockets.
Nothing bad will happen it's just a no-op.
Ok so you've got React in your package.json and it precompiles successfully. Can you navigate to where your JS files should be served on your production server? Is your HTML referencing that file? What happens when you ReactRailsUJS.handleMount() directly?
We will need more information to help you diagnose this, please try answer all the questions above if you can.
@BookOfGreg, my Application compiles successfully and ./bin/webpack-dev-server shows no error at all, also I am precompiled assets using the "rake assets:precompile RAILS_ENV=production" command and have also tried with "config.assest.compile = true " in production.rb.
My HTML shows just
"<div data-react-class="index" data-react-props="{}"></div>"
and have this
Loading failed for the
Most helpful comment
Glad you have it fixed and it was just an asset serving issue. Enjoy using React-rails!