Skip to content

Require.context not working after installing sentry on Next.js project #6961

Description

@dorianw123

Environment

SaaS (https://sentry.io/)

Version

No response

Link

No response

DSN

No response

Steps to Reproduce

I've installed sentry on my Next.js project. I'm trying to use require.context like so:

const flagImages = importAll(
require.context("../../public/images/flags", false, /\.(png|jpe?g|svg)$/)
);

This was working fine before installing sentry, but doesn't work after installing sentry. I assume the reason it no longer works is because sentry changes the webpack configuration.

I tried using import.meta.webpackContext as the ESM alternative to require.context, but this didn't work either - I just get import.meta.webpackContext is undefined.

Expected Result

Should be able to use require.context or import.meta.webpackContext

Actual Result

image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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