nuxt-config-schema
This is a proof of concept module for a feature in Nuxt 3 that automatically infers and generates schema based on user provided configuration from several sources using unjs/untyped and supports extending layers.
136,084
| Install | |
|---|---|
npm install nuxt-config-schema |
|
| Latest Version: | 0.4.7 |
| Vue: | 3 |
| License: | MIT |
| Last Updated: | Nov 5, 2024 |
| Links: | npm |
Maintainer: pi0
Nuxt Config Schema
This is a proof of concept module for a feature in Nuxt 3 that automatically infers and generates schema based on user provided configuration from several sources using unjs/untyped and supports extending layers.
Schema can be defined in nuxt.schema.ts or $schema field in nuxt.config.ts.
Read the proposal for Nuxt 3
This experiment is landed to Nuxt 3 core since 3.1.0 (https://github.com/nuxt/nuxt/pull/18410)
Usage
- Install
nuxt-config-schemaas dev dependency:
# npm
npm i -D nuxt-config-schema
# pnpm
pnpm add -D nuxt-config-schema
# yarn
yarn add nuxt-config-schema
- Add module to
nuxt.config:
export default defineNuxtConfig({
modules: ['nuxt-config-schema'],
})
- Create
nuxt.schema.ts:
export default defineNuxtConfigSchema({
appConfig: {
test2: {
$default: 'from nuxt.schema',
},
},
/** Config schema for another integration */
anotherConfig: {
aTest: '123',
},
})
- Use
nuxi devornuxi buildcommands
You can access generated schema (json, markdown and types) from .nuxt/schema/ directory and also hooks below:
schema:extend(schemaDefs): Extend schema defenitions (first call aftermodules:donehook)schema:resolved(schema): Extend resolved schema after merging (first call aftermodules:donehook)schema:beforeWrite(schema): Extend resolved schema just before writing to filesystem (called afterbuild:donehook)schema:written: Hook will be called when schema has been written and updated to filesystem
Development
- Run
npm run dev:prepareto generate type stubs. - Use
npm run devto start playground in development mode.
Version History
| Version | Released | License |
|---|---|---|
| 0.4.7 | MIT | |
| 0.4.6 | MIT | |
| 0.4.5 | MIT | |
| 0.4.4 | MIT | |
| 0.4.3 | MIT | |
| 0.4.2 | MIT | |
| 0.4.1 | MIT | |
| 0.4.0 | MIT | |
| 0.3.8 | MIT | |
| 0.3.7 | MIT | |
| 0.3.6 | MIT | |
| 0.3.5 | MIT | |
| 0.3.4 | MIT | |
| 0.3.3 | MIT | |
| 0.3.2 | MIT | |
| 0.3.1 | MIT | |
| 0.3.0 | MIT | |
| 0.2.1 | MIT | |
| 0.2.0 | MIT | |
| 0.1.0 | MIT |