I am working with Laravel 5.6
and building my app.js
with webpack
.
I installed with npm
perfect-scrollbar but I cannot get it to work. When I load the page I get:
Uncaught TypeError: $(...).perfectScrollbar is not a function
My js bootstrap is:
try {
window.$ = window.jQuery = require('jquery');
require('popper.js/dist/umd/popper');
require('./bootstrap/bootstrap.bundle');
} catch (e) {
}
import PerfectScrollbar from 'perfect-scrollbar';
I have also tried:
const PerfectScrollbar = require('perfect-scrollbar');
window.PerfectScrollbar = require('perfect-scrollbar');
I initialise the scroll bar like this:
$('.sidebar .sidebar-wrapper, .main-panel').perfectScrollbar();
If I load the perfect-scrollbar
code via CDN after my app.js
then my code works.
How do I correctly import perfect-scrollbar
and make it available to the global scope of the code?