Next.js: Add resolver to root dir

Created on 20 Mar 2017  路  6Comments  路  Source: vercel/next.js

Guys, Next today not working with non-relative paths. I was thinking in implement something using that: https://github.com/tleunen/babel-plugin-module-resolver

The big deal is: When use a custom server, with a custom DIR, where in next can I edit the babel settings for look the root as the config dir and not the original root dir?

Most helpful comment

I think there's something similar too.
We are not going to do this in the core.

Just simply add a babel-plugin. I prefer this: https://github.com/tleunen/babel-plugin-module-resolver

And @fdaciuk mentioned some other cases too.
We'll may think something about this later on. But not now.

All 6 comments

Are you looking for something like this?

Anyway, could you explain a bit more about what you are trying to achieve?

@arunoda I think that both have the same solution with different approaches. The point here, is why not do this in Next .babelrc point to the root dir of the project. :thinking:

The point here, is why not do this in Next .babelrc point to the root dir of the project

Sorry. I didn't get this?

The last time that I tried, next not have module-resolver in your core @arunoda. I had to use relative paths everywhere, in a structure with many namespaces, we need to use much ../../../ and this can be a little confuse. My ideia is implements one of this plugins in next for people can call modules direct from root and stop to using relative :)

@guidiego you can make your own webpack configuration, adding alias to solve this problem.

To use this in server side, just use module-alias.

This way worked for me =)

I think there's something similar too.
We are not going to do this in the core.

Just simply add a babel-plugin. I prefer this: https://github.com/tleunen/babel-plugin-module-resolver

And @fdaciuk mentioned some other cases too.
We'll may think something about this later on. But not now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

timneutkens picture timneutkens  路  3Comments

olifante picture olifante  路  3Comments

formula349 picture formula349  路  3Comments

pie6k picture pie6k  路  3Comments

sospedra picture sospedra  路  3Comments