Is it possible to define a public assets folder inside a nuxt 3 module ?
sppmstar opened this issue · 1 comments
Hi,
I have a silly question, but I think it might be worth asking here to help other folks running into the same issue...
I am experimenting with Nuxt 3 modules to see if we could use it to develop micro frontends. I have been successful at adding custom layouts and extend pages and adding component folders, but i was wondering : is there a way to define / add a public folder for static assets such as images and whatnot ?
The reason I am asking is because I am trying to have all the assets of the micro frontend encapsulated inside the module source code. It does work if i put the images inside the public folder under /playground, but this means that the app consuming the module would need to be responsible for hosting the images required by a module.
I hope it makes sense ? I tried to use addAutoImportDir
, but it did not seem to yield the result i was expecting...
So, to summarize: how can I configure a public folder from within my module, and have it served by the playground / host application the same way it does when adding a public
folder inside a Nuxt application ?
Yes, you can. You can push a directory to nuxt.options.nitro.publicAssets
You might also use the extends feature, which will automatically do this for a public/
folder within an extended nuxt folder.