bash
$ yarn add jquery
config/webpack/environment.js
const { environment } = require('@rails/webpacker');
const webpack = require('webpack');
environment.plugins.append('Provide',
new webpack.ProvidePlugin({
$: 'jquery/src/jquery',
jQuery: 'jquery/src/jquery'
})
);
module.exports = environment;
app/javascript/packs/application.js
//add to
require('jquery');
OK if the version is displayed on the console of the developer tools.
console
console.log($.fn.jquery);
// 3.5.1
Recommended Posts