Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom extensions with priority #3445

Closed
coluccini opened this issue Dec 12, 2017 · 5 comments · Fixed by #3578
Closed

Custom extensions with priority #3445

coluccini opened this issue Dec 12, 2017 · 5 comments · Fixed by #3578

Comments

@coluccini
Copy link
Contributor

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…

@coluccini
Copy link
Contributor Author

@timneutkens do you think this PR -> #2391 will add what I need to achieve this?

@timneutkens
Copy link
Member

@coluccini, so, there's one question I have, do you want this to work for pages too or not. I'm expecting it's not needed. In that case you can do what you want to do in next.js v5 because webpack will run on the server and client side 👍

@coluccini
Copy link
Contributor Author

Excellent! I don't need this to work on pages :)
Do you know if there is a estimated date to the v5 release?

@timneutkens
Copy link
Member

timneutkens commented Jan 17, 2018

Excellent! I don't need this to work on pages :)

Great!

Do you know if there is a estimated date to the v5 release?

No definitive date, but I'm working on the final bits of universal webpack 👍

@coluccini
Copy link
Contributor Author

so I'll be watching you! 🤣
Thanks!

@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants