$ is not defined when installing jQuery in Rails via Webpack
The code in config/webpack/environment.js
should look like this:
environment.plugins.prepend('Provide',
new webpack.ProvidePlugin({
$: 'jquery/src/jquery',
jQuery: 'jquery/src/jquery'
})
)
see also https://www.botreetechnologies.com/blog/introducing-jquery-in-rails-6-using-webpacker
I've got what's missing.
In app/javascript/packs/application.js
forgot to declare:
window.jQuery = $;
window.$ = $;
So jQuery keywords could be picked up.