I generate a new rails app :
rails new titi --webpack=vue
and would like to use jQuery (or other libs like popper, vue-resource...).
I tried to yarn add jquery
which was fine, but I don't have access to jQuery in my JavaScript code.
In previous Webpacker gem, there was much more conf and I had to write this in shared.js
:
module.exports = {
...
plugins: [
...
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
]
...
resolve: {
extensions: settings.extensions,
modules: [
resolve(settings.source_path),
'node_modules'
],
alias: {
jquery: "jquery/src/jquery",
vue: "vue/dist/vue.js",
vue_resource: "vue-resource/dist/vue-resource",
}
}
What is the cleanest way to include libraries in current Webpacker version ? Something in config/webpacker.yml
?
Thanks. That's fine with gem Webpacker 2, but new version of the Gem has a new organisation for files and requires less config.
For Webpack 3,
shared.js
doesn't seem to be mandatory. Instead, I wrote the config inconfig/webpack/environment.js
like this :