How to reduce path of static file use NextJSv13?
Answered
Asian black bear posted this in #help-forum
Asian black bearOP
Hi,
I have no idea to reduce path of serving static file?.
I export Images like code:
sorry if the question sounds stupid but I can't find any solution on web.
I have no idea to reduce path of serving static file?.
I export Images like code:
import laptop from '../../../public/static/.../.../laptop.svg';
export const Images: Record<string, any> = {
laptop,
};
sorry if the question sounds stupid but I can't find any solution on web.
Answered by Clown
The default create-next-app project with typescript already sets your root folder as
@
so you can import stuff from public folder as:import img from "@/public/next.svg";
2 Replies
The default create-next-app project with typescript already sets your root folder as
@
so you can import stuff from public folder as:import img from "@/public/next.svg";
Answer
You can take a look at
Here is the reference if you want to add additional paths: https://www.typescriptlang.org/tsconfig#paths
As an additional note, this should still be available even if you are using javascript by default.
paths
inside tsconfig.json
in your root directory.Here is the reference if you want to add additional paths: https://www.typescriptlang.org/tsconfig#paths
As an additional note, this should still be available even if you are using javascript by default.