Gatsby: How to implement owl carousel in gatsby with react

Created on 30 Jun 2019  路  4Comments  路  Source: gatsbyjs/gatsby

Hello,
I want to use owl carousel in my gatsby project.
I am using https://www.npmjs.com/package/react-owl-carousel this library .
But can not configure the settings.
Also can not understand where should I place the webpack configuration.
Any help is much appreciated.
Thanks.

question or discussion

Most helpful comment

Is that you need to use jQuery with react-owl-carousel ?
Because the documentation also mention you can use html script tag to inject jquery as well.
Here is how you can customize html in gatsby:
https://www.gatsbyjs.org/docs/custom-html/
Also here if you want to customize webpack:
https://www.gatsbyjs.org/docs/add-custom-webpack-config/

All 4 comments

Is that you need to use jQuery with react-owl-carousel ?
Because the documentation also mention you can use html script tag to inject jquery as well.
Here is how you can customize html in gatsby:
https://www.gatsbyjs.org/docs/custom-html/
Also here if you want to customize webpack:
https://www.gatsbyjs.org/docs/add-custom-webpack-config/

This solution works for me.
Thanks @duongthienlee for the resource.

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

Thanks.

Issue seems resolved, so I'll close it.

@anamwp can you show the import for the webpack namespace?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

magicly picture magicly  路  3Comments

hobochild picture hobochild  路  3Comments

3CordGuy picture 3CordGuy  路  3Comments

KyleAMathews picture KyleAMathews  路  3Comments

ghost picture ghost  路  3Comments