I tried to use Bootstrap 4's Collapse with Webpack, but the browser gives me the following error:
jquery__WEBPACK_IMPORTED_MODULE_0___default(...)(...).collapse is not a function
The JS file is this:
import $ from 'jquery';
import '@popperjs/core';
import 'bootstrap';
import 'bootstrap/dist/css/bootstrap.min.css';
$(function ()
{
$('.collapse').collapse();
});
Webpack's transpilation is ok, but when I hit the page the browser's console shows the error above. Apparently, Webpack is not loading the Collapse plugin into the jQuery object, but I can't figure out why. I also tried to import the plugin individually, but the outcome is the same.