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

Using Rails asset pipeliine and react_on_rails together, working?


#1

I have a Rails 5.1, react_on rails v10, app which runs locally and on heroku. It is a work in progress
and not in production. My react components are working just fine, but I now realize I need to serve up some html documentation and results from the rails side, I added a route and controller, but when I hit an index page,
when it loads, it finds that it can’t find the application.js file.

Details of the error/
Showing /Users/frankatjackrabbit/src/fortran_calculus_portal_react/app/views/layouts/application.html.erb where line #7 raised:

The asset “application.js” is not present in the asset pipeline.

<%= csrf_meta_tags %>
<%= stylesheet_link_tag    'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>                           << HERE
<%= javascript_pack_tag 'webpack-bundle' %>

<meta charset="utf-8">

Rails.root: /Users/frankatjackrabbit/src/fortran_calculus_portal_react
End Details/

I will post more details if this should have been working but I just wanted to ask the queston:

Question. when I use react_on_rails, with your stack serving up the assets, is the rails asset pipeline, on or off; do I need to do anything to turn it on? I am under the impression I can have both.

Any quick guesses as to why this is failing?
I have a manifest.js with app/assets/config/manifest.js
//= link_tree …/images
//= link_directory …/javascripts .js
//= link_directory …/stylesheets .css
I don’t have any .js, .scss, or .css files yet; the images, javascripts, stylesheets, directories exist and are empty.

Thoughts?

www.github.com/fgermanojr/fcportal is the repo
frank-germano-jr.org is a description of progress

Thanks.


#2

Using React on Rails des not turn off the asset pipeline. The rails/webpacker helpers avoid double minifications of assets.