framework
framework copied to clipboard
feat(nuxt): config default keepalive, page & layout transitions
🔗 Linked issue
resolves #5729
❓ Type of change
- [ ] 📖 Documentation (updates to the documentation or readme)
- [ ] 🐞 Bug fix (a non-breaking change that fixes an issue)
- [x] 👌 Enhancement (improving an existing functionality like performance)
- [ ] ✨ New feature (a non-breaking change that adds functionality)
- [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to change)
📚 Description
This allows support for configuring page & layout transition default values, as well as keepalive. (Otherwise there is the tedious task of doing so for every individual file.)
In order to do this, we now inject #build/app.config.mjs
to automatically expose all values within the app
key in Nuxt config, rather than creating ever-more virtual files for particular use-cases. (We would, for example, have had to do this for layouts and page transitions separately otherwise.) This means we were able to drop meta.config.mjs
and in general is a useful pattern for future app
configuration.
📝 Checklist
- [x] I have linked an issue or discussion.
- [x] I have updated the documentation accordingly.
Deploy Preview for nuxt3-docs canceled.
Name | Link |
---|---|
Latest commit | a414fcd4765f7cd816337908bc95ea81ec244eea |
Latest deploy log | https://app.netlify.com/sites/nuxt3-docs/deploys/6304c375fa5ce1000818a2af |
Thanks for rebasing. Shall we type appConfig.nuxt
from schema now?
Beautiful work @danielroe ❤️
Shall we document more to use app.config.ts
for such configurations from now on?
Shall we document more to use app.config.ts for such configurations from now on?
Currently, usage of useAppConfig().nuxt
is kinda internal. For some, we might have built-time optimization opportunities (like not bundling transition bytes) while if we make users able to set via app.config
, we cannot do this anymore as such config can be changed on runtime. I suggest not adding nuxt
types from AppConfigInput
as well for this PR (keep marking it as never
for input but typing for AppConfig)
(fixture seems broken)
Could we take this opportunity to also give the possibility to set those values to false
to disable keepalive, page & layout transitions?
Indeed, that is one of the key use-cases of this PR. As implemented here, it is possible to set them to false and it will disable keepalive, page & layout transitions.
Thinking more about approaches, i think for specific nuxt bundled config, using an internal template with named exports (#build/nuxt.config.mjs
?) could be safer since we probably don't need nor could support HMR for these configs originating from nuxt.config
and it makes it consistent with feature plans being able to treeshake at build time (appConfig is totally runtime-dynamic. we cannot depend on it for this unless passing another build flag)
Okay - so just to confirm, we'll refactor back to original approach of this PR, but using nuxt.config.mjs
filename?