Add Jquery in Rails

Reference Link :: 

https://www.botreetechnologies.com/blog/rails-6-jquery-upgrade-with-webpacker/


Step 01 ::   

$ bundle exec rails webpacker:install

Step 02 ::

$ yarn upgrade

Step 03 ::

$ yarn add jquery

Step 04 ::  Add require jquery

config/webpack/environment.js

Add this code between const and moudle export enviornment

const { environment } = require('@rails/webpacker')

const webpack = require('webpack')

environment.plugins.prepend('Provide',

new webpack.ProvidePlugin({

$: 'jquery/src/jquery',

jQuery: 'jquery/src/jquery'

})

)

module.exports = environment

Step 05 ::Add this code in downside file

<codeapp/javascript/packs/application.js

require("jquery")



Comments

Popular posts from this blog

Rails 7 Features :: Comparison with Rails 6 and Rails 5