简体   繁体   中英

How to use Webpacker in Rails 5.2.2?

I'm starting to learn to use React with Rails. In application.html.erb I replaced

<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>

with

<%= javascript_pack_tag    'application', 'data-turbolinks-track': 'reload' %>

How do I require everything from the /assets/javascripts/application.js file?

//= require rails-ujs
//= require activestorage
//= require turbolinks
//= require cookies_eu
//= require_tree .
//= require jquery3
//= require popper
//= require bootstrap

Do I import them all at the beginning of the /javascript/packs/application.js file?

Based on a tutorial I watched, I can just keep also the:

 <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>

Then everything will be loaded, though not via Webpack.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM