Reputation: 1456
I am traditionally came from Vue and i kinda like to have the same import { } from '@/whatever and the location seems like having many dot dot import {} from './../../from/source/file
Please let me know if you have any installation during this kinda process
Upvotes: 0
Views: 1339
Reputation: 1456
Thank you for you answer i kinda like to have ~/file/file so i created this short configuration
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"~/*": ["src/*"]
}
}
}
Upvotes: 0
Reputation: 8982
You can do this by editing the paths
property the jsconfig.json. If you would like to have a shortcut for graphql, you could do this for example:
// jsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"graphql/*": ["graphql/*"]
}
}
}
Your import
statement would so shorten to this:
import { ADD_USER_MUTATION } from "graphql/mutations"
import { GET_USER_BY_EMAIL_QUERY } from "graphql/queries"
This only works if on the graphql folder is in the root directory. Read more about this here.
Upvotes: 2
Reputation: 3123
Yes it's possible to do that in Next.js, it is explained in the documentation and no installation during the process
Upvotes: 4