Relocate public directory?
Answered
Spinge Bib Sqorpnts posted this in #help-forum
Is it possible to configure a directory, outside the project root, to act as the
public/
directory? I have a monorepo and I want multiple projects to share the same public/
dirAnswered by joulev
i don't think it is possible. in cases like this i just use symlinks: make a public folder in the nextjs project that is a symlink to the actual shared public folder. then nextjs should still pick it up but you only have to maintain one public folder.
7 Replies
Or rather an even better solution, allow each project to have their own
public/
directory, along with shared assetsi don't think it is possible. in cases like this i just use symlinks: make a public folder in the nextjs project that is a symlink to the actual shared public folder. then nextjs should still pick it up but you only have to maintain one public folder.
Answer
Unfortunate :/
Thought of symlinks as last resort, because I'm worried it'll screw up all my paths
Thought of symlinks as last resort, because I'm worried it'll screw up all my paths
Thanks for the help :)
yeah i think the name
public
is hardcoded in the nextjs source code already, there isn't much you can do except symlinks. the public
folder is not configurable.imo it sounds like a good feature request, I might open an issue later
https://github.com/vercel/next.js/blob/49f9c46fb13cce03e37b9eccfdba1e12b9e2650e/packages/next/src/server/lib/router-utils/filesystem.ts#L136 yup the name
public
is hardcoded and not configurable.