Skip to content

React Contentful not building with VITE #250

@bondia

Description

@bondia

I moved an old project that uses "react-contenful" to use Vite instead of Webpack.
On dev mode it runs OK but when building "react-contentful" it fails on the browser.

index.4dc67e6f.js:41 Uncaught ReferenceError: require is not defined

Screenshot 2022-07-18 at 08 59 11

The problem is that it is using require in client side.

const { createClient } = require('contentful');

Might be that it needs an import instead?
Any idea what is the underlying issue here?

Thanks a lot!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions