Rails 5/6: How to include JS functions with webpacker?

For instructions on moving from the old asset pipeline to the new webpacker way of doing things, you can see here: https://www.calleerlandsson.com/replacing-sprockets-with-webpacker-for-javascript-in-rails-5-2/ This is a howto for moving from the asset pipeline to webpacker in Rails 5.2, and it gives you an idea of how things are different in Rails 6 now that webpacker is … Read more

How to add jquery third party plugin in rails 6 webpacker

run below command to add jQuery. $ yarn add jquery Add below code in config/webpack/environment.js const webpack = require(‘webpack’) environment.plugins.prepend(‘Provide’, new webpack.ProvidePlugin({ $: ‘jquery/src/jquery’, jQuery: ‘jquery/src/jquery’ }) ) Require jquery in application.js file. require(‘jquery’) No more need to add jquery-rails gem!