json-schema-artifact
v2.0.3
Published
JSON Schema bundler
Downloads
41
Readme
Installation
npm install --save-dev json-schema-artifactUsage
- Create a configuration file
json-schema-artifact.mjs(or.json,.yaml,.yml,.ts,.mjs) in your workspace root:
- ESM Format (Recommended):
import { defineConfig } from "json-schema-artifact";
export default defineConfig([
{
input: {
file: "src/example.json"
// locales: {
// zh_CN: "locales/zh_CN.yaml",
// en: "locales/en.yaml",
// ru: "locales/ru.yaml"
// }
},
output: {
dir: "dist",
optimize: {
minify: true,
dereference: "flatten"
}
},
watch: ["src", "locales"]
}
]);- JSON Format:
[
{
"input": {
"file": "src/example.json"
// "locales": {
// "zh_CN": "locales/zh_CN.yaml",
// "en": "locales/en.yaml",
// "ru": "locales/ru.yaml"
// }
},
"output": {
"dir": "dist",
"optimize": {
"minify": true,
"dereference": "flatten"
}
},
"watch": ["src", "locales"]
}
]- This configuration watches all files in
srcandlocales, triggering rebuilds on changes. - Localization configuration (optional):
- Configure locales with language files (JSON or YAML format).
- Use t(`key`) syntax (where
keyis a JSONPath expression that targets the corresponding value in locale files).
- Start development with watch mode (use
--configfor custom config paths):
npx json-schema-artifact --watchAdd schema validation to .vscode/settings.json:
{
"json.schemas": [
{
"url": "./dist/example.json",
"fileMatch": ["test/example-test-data.json"]
}
]
}- Build JSON Schema artifacts:
npx json-schema-artifactExample
You can find an example here.
