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
//ajouter à
require('jquery');
OK si la version est affichée sur la console des outils de développement.
console
console.log($.fn.jquery);
// 3.5.1
Recommended Posts