Skip to content

Instantly share code, notes, and snippets.

@brunos3d
Last active July 13, 2022 18:41
Show Gist options
  • Save brunos3d/6fdb8ae307cc576667c97778030dfd91 to your computer and use it in GitHub Desktop.
Save brunos3d/6fdb8ae307cc576667c97778030dfd91 to your computer and use it in GitHub Desktop.
How to use multiple schemas in one json file

Nx project json example

To make json schema intellisense work in vscode with Nx configurations use $ref in order to use $schema

{
-  "$schema": "../../node_modules/nx/schemas/project-schema.json",
+  "$ref": "file:../../node_modules/nx/schemas/project-schema.json",
  // ...
}

Also you can add custom schemas with more refs

image

image

{
"$ref": "file:../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/checkout",
"projectType": "application",
"targets": {
"build": {
"executor": "@nrwl/next:build",
"outputs": ["{options.outputPath}"],
"defaultConfiguration": "production",
"options": {
"root": "apps/checkout",
"outputPath": "dist/apps/checkout"
},
"configurations": {
"development": {
"$ref": "file:../../node_modules/@nrwl/next/src/executors/build/schema.json"
},
"production": {
"$ref": "file:../../node_modules/@nrwl/next/src/executors/build/schema.json"
}
}
},
"serve": {
"executor": "@nrwl/next:server",
"defaultConfiguration": "development",
"options": {
"buildTarget": "checkout:build",
"dev": true,
"port": 4200
},
"configurations": {
"development": {
"buildTarget": "checkout:build:development",
"dev": true
},
"production": {
"buildTarget": "checkout:build:production",
"dev": false
}
}
},
"export": {
"executor": "@nrwl/next:export",
"options": {
"buildTarget": "checkout:build:production"
}
},
"test": {
"executor": "@nrwl/jest:jest",
"outputs": ["coverage/apps/checkout"],
"options": {
"jestConfig": "apps/checkout/jest.config.ts",
"passWithNoTests": true
}
},
"lint": {
"executor": "@nrwl/linter:eslint",
"outputs": ["{options.outputFile}"],
"options": {
"lintFilePatterns": ["apps/checkout/**/*.{ts,tsx,js,jsx}"]
}
}
},
"tags": []
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment