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
Post a Comment