I want to use jQuery owl carousel with my next js react app.
I dont want to use npm package react-owl-carousel only owl-carousel and jquery plugin.
I use lazy load with next.js dynamic and put the following code in my Webpack config:
import dynamic from 'next/dynamic';
const Slider = dynamic(() => import('...'), {
ssr: false,
});
Webpack config:
config.plugins.push(new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
}));
Slider component:
import 'owl.carousel';
import 'owl.carousel/dist/assets/owl.carousel.css';
When I use $('element').owlCarousel(...), I got the following error:
TypeError: this.owl.owlCarousel is not a function