[JAVA] [Rails] Introducing jquery

I often used jquery in application development, so I summarized the introduction method. ** Rails version is 6.0.0. ** **

Terminal
yarn add jquery

config/webpack/environment.js


const { environment } = require('@rails/webpacker')
#Postscript
const webpack = require('webpack')
environment.plugins.prepend('Provide',
    new webpack.ProvidePlugin({
        $: 'jquery/src/jquery',
        jQuery: 'jquery/src/jquery'
    })
)
#So far
module.exports = environment

app/javascript/packs/application.js


require('jquery')  #Postscript
require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")
require("../category")
require("../category_post")

Recommended Posts

[Rails] Introducing jquery
Rails6 jQuery introduced
[Rails] Introducing devise
[Rails] Use jQuery
Introducing CircleCI to Rails
Introducing Bootstrap to Rails 5
Introducing Bootstrap to Rails !!
[Rails] Introducing Active Hash
Introducing Rails6 + Bootswatch / Honoka
Introducing Bootstrap and Font-Awesome (Rails)
How to deploy jQuery on Rails
Enable jQuery and Bootstrap in Rails 6 (Rails 6)
Introducing full calendar to Rails application
How to introduce jQuery in Rails 6
Introducing React to Rails with react-rails
Timeless search with Rails + JavaScript (jQuery)
[Rails g.error]
Introducing devise
Rails basics
Rails Review 1
Rails API
Rails migration
[Rails] first_or_initialize
Introducing RSpec
rails tutorial
About Rails 6
Rails foundation
Rails memorandum
rails tutorial
rails tutorial
rails tutorial
[Rails 6] Introducing Google Maps to your portfolio
Preparing to introduce jQuery to Ruby on Rails
[Rails] devise
Introducing devise
rails tutorial
rails tutorial
The process of introducing Vuetify to Rails
Rails Tips
rails method
rails tutorial
[Rails] ActiveRecord
[Rails] form_with
Rails Review 2
Introducing Rspec with Ruby on Rails x Docker
Introducing New Relic to Rails apps on Heroku
Introducing Rspec, a Ruby on Rails test framework
How to use JQuery in js.erb of Rails6
[Rails] Introducing pay.jp (from view customization to registration)