Skip to content

Custom extensions with priority #3445

@coluccini

Description

@coluccini

Hi!
I would like to achieve something similar to what React Native does with the .android.js and .ios.js extensions. The idea is to have 2 different "extensions" and "decide" which one to use base on an env var.

I've made a quick test using create-react-app and I achieved it by using this webpack config:

resolve: {
  extensions: [`.${process.env.VAR}.js`, '.js'],
  ...
}

Lets say that process.env.VAR is foo, if I import Component, webpack will first try to find Component.foo.js and if doesn't exist will search for Component.js.

Is there a way to do something similar in Next? Reading a few issues I've found a pagesExtensions existing in next.config.js but I'm not sure if work similar to webpack's extensions config…

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions