Read and set a value to use inside of template during build time
I want to access my project's version inside my template, the "version" field in
package.json
. I'd like to get it programmatically instead of having to manually update it, since it's going to be updated with bumpp
on releases.
Is it possible for me to make nuxt, at some point in the build step (and ideally in dev too) read package.json
file then set like useRuntimeConfig().public.appVersion
?2 Replies
You can import your package.json and add a property to
nuxt.config.ts
Then access it like useAppConfig().appVersion
Thanks, it works