I m wondering about the …

1 minute read

I’m wondering about the build output for the next apps. How are public assets being treated, if at all? Usually with next I just have a public folder in the root that is served as a static folder directly for things like favicon etc. D That isn’t included in the build output in dist/apps/* though, so wondering if there’s a different approach preferred or perhaps this just hasn’t been considered yet?


You can use the apps/<appname>/assets folder, this will be copied over and exists as assets in your final dist

that doesn’t seem to be happening for the next app, I get a package.json and a .next folder, which does not include assets (or public for that matter)


Just confirmed, I see the same thing in a fresh nx-next sandbox

Probably worth to create an issue for it. At list I’d assume it would work that way

Exactly. One could even argue that copying the public folder (if it exists) next to the build output makes sense since the output is meant to be able to be deployed directly and it’s a supported feature of next.js

I’ll create an issue, thanks for your input

Oh, it seems to already exist, awesome. https://github.com/nrwl/nx/issues/3019

just a quick question on this - I’m not a Next developer, but my understanding was that you would reference any .svg etc. asset in your components, and they’d get picked up by the bundler and would end up in your dist folder that way.

Are requesting this because you want an assets folder that is not referenced from your components, and cannot be picked up by the bundler?

I do believe assets and public have different purposes so keeping both might be the way to go.

The convention in nx apps seems to be that assets are to be imported into code, and that does get picked up by the nextjs bundler like you said.

Meanwhile public is used by next for static file serving (https://nextjs.org/docs/basic-features/static-file-serving)

I see what you mean! Thanks for linking that! I tried to replicate here: https://github.com/rarmatei/next-js-assets , and indeed, the image disappears once I remove the root public folder (I thought doing a next build would put everything I need in the .next folder :thinking_face: )