Skip to content

Conversation

@ashfame
Copy link
Member

@ashfame ashfame commented Dec 9, 2024

Added a custom webpack plugin EmitMergedJsonPlugin that:

  • Reads all JSON files from a specified source directory
  • Merges them into a single JSON object
  • Outputs the merged schema to multiple locations:
    • Build directory
    • WordPress plugin src dir

Next, we need to figure out the output paths, but that can happen in the PR which starts using the generated schema file.

closes #144


Output sample:

cat build/firefox/schema.json
{
  "page": {
    "title": "Page",
    "fields": {
      "title": "String",
      "content": "String"
    }
  },
  "post": {
    "title": "Blog Post",
    "fields": {
      "date": {
        "type": "Date",
        "description": "date of the post",
        "required": true
      },
      "author": "String",
      "title": "String",
      "content": "String"
    }
  },
  "product": {
    "title": "Product",
    "fields": {
      "title": "ProductString",
      "description": "String",
      "price": "currency"
    }
  }
}

  - Reads all JSON files from a specified source directory
  - Merges them into a single JSON object
  - Outputs the merged schema to multiple locations:
    - Build directory (webpack output)
    - Configured output paths (dist/config, public/config)
@ashfame ashfame self-assigned this Dec 9, 2024
@ashfame ashfame requested a review from psrpinto December 9, 2024 15:44
Copy link
Member

@psrpinto psrpinto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks for working on this!

@ashfame ashfame requested a review from psrpinto December 9, 2024 16:32
Copy link
Member

@psrpinto psrpinto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

@ashfame ashfame merged commit 2868b25 into trunk Dec 10, 2024
3 checks passed
@ashfame ashfame deleted the build_merge_json_schema branch December 10, 2024 07:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a build process for JSON Schemas

3 participants