Skip to content

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

Closed
@dorianw123

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: nextjsIssues related to the Sentry Nextjs SDK

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions