$ echo 'gem "webpacker"' >> Gemfile
$ bundle install
$ rails webpacker:install
$ yarn add [email protected] jquery popper.js
diff --git a/config/webpack/environment.js b/config/webpack/environment.js
index d16d9af..86bf1a7 100644
--- a/config/webpack/environment.js
+++ b/config/webpack/environment.js
@@ -1,3 +1,10 @@
const { environment } = require('@rails/webpacker')
+const webpack = require('webpack')
+environment.plugins.set('Provide', new webpack.ProvidePlugin({
+ $: 'jquery',
+ jQuery: 'jquery',
+ Popper: ['popper.js', 'default']
+}))
+
module.exports = environment
// app/javascript/packs/bootstrap.scss
@import '~bootstrap/dist/css/bootstrap';
// app/javascript/packs/applicatoin.js
import 'bootstrap/dist/js/bootstrap';
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -6,6 +6,8 @@
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
+ <%= javascript_pack_tag 'application' %>
+ <%= stylesheet_pack_tag 'bootstrap' %>
</head>
<body>
The error I was getting + fix that worked for me: https://stackoverflow.com/questions/49107725/i-got-webpacker-error-when-running-the-rails-app-typeerror-environment-plugin