Updating our Gemfile
Update the gem in the gem file
After mentioning the webpacker gem with the latest version, we need to run the bundle install and it will update the gem. Now we can use the latest webpacker.
Install the WebPacker If not installed
If the webpacker does not exist in application then we need to install the Webpacker by the following command : bin/rails webpacker:install it will install the webpacker in your application.
How to use Jquery with WebPacker
In rails application to use the jquery with webpacker it’s different. Here, we’ve shown how to require the Jquery.
Here we have required the Jquery and the app-globals.js is a file where the jquery is written and we need to change the environment.js file as well.Which is in the config/webpack/environment.js in this directory.