gatsbyjs / gatsby-source-wordpress-experimental

The upcoming v4 of gatsby-source-wordpress, currently in beta
MIT License
385 stars 100 forks source link

How to include jQuery via webpack plugin #445

Closed meekmachine closed 3 years ago

meekmachine commented 3 years ago

Hello,

I was trying to add react-owl-carousel plugin, to the Gatsby Wordpress site I am working on. I am adding jquery by including the following code in the gatsby-node.js, as per the instructions here: https://github.com/laurenchen0631/react-owl-carousel

However it says "TypeError: $ is undefined"

const jquery = require(jquery) exports.onCreateWebpackConfig = ({ stage, rules, loaders, plugins, actions }) => { actions.setWebpackConfig({ plugins: [ new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery', 'window.jQuery': 'jquery' }), ] }); };

Any idea how to fix this?

meekmachine commented 3 years ago

Fixed this by just inserting a script tag in my index.html.