@jackwilsdon/craco-json-schema-dereferencer

1.0.1 • Public • Published

craco-json-schema-dereferencer

A craco plugin that adds JSON Schema dereferencing to create-react-app 2.

Powered by @cloudflare/json-schema-ref-loader

Installation

Make sure you have craco installed before continuing. You can find the official installation instructions here.

You can then install craco-json-schema-dereferencer using your package manager of choice;

npm install --save @jackwilsdon/craco-json-schema-dereferencer
yarn add @jackwilsdon/craco-json-schema-dereferencer

Usage

The plugin provides a few options to allow the inclusion and exclusion of files;

{
  // The expression to match to include files.
  // Default: /\.json$/ (i.e. files ending with .json)
  test: ...,
  // The condition to match to include files.
  // Default: the app's source directory
  include: ...,
}

See the webpack condition documentation for possible test and include values.

These options can be passed under the options property of the plugin;

// craco.config.js
const DereferencerPlugin = require('@jackwilsdon/craco-json-schema-dereferencer');
const path = require('path');

module.exports = {
  plugins: [
    {
      plugin: DereferencerPlugin,
      options: {
        // Only dereference .schema.json files.
        test: /\.schema\.json/,
        // Only dereference files in the schemas directory.
        include: path.join(__dirname, 'src', 'schemas'),
      },
    },
  ],
};

Package Sidebar

Install

npm i @jackwilsdon/craco-json-schema-dereferencer

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

4.45 kB

Total Files

4

Last publish

Collaborators

  • jackwilsdon