JSPM

@percy/config

1.0.0-beta.18
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 415827
  • Score
    100M100P100Q176473F
  • License MIT

Package Exports

  • @percy/config

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@percy/config) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@percy/config

Handles loading and adding options to Percy configuration files. Uses cosmiconfig to load configuration files and JSON schema with AJV to validate those configuration files.

Usage

Loading config files

The .load() method will load and validate a configuation file, optionally merging it with any provided overrides. If no path is provided, will search for the first supported config found from the current directory up to the home directoy. Configuration files are cached and reused unless reload is true.

import PercyConfig from '@percy/config'

// loading is done synchronously
const config = PercyConfig.load({
  path,            // config file path or directory path containing a config file
  overrides = {},  // configuration option overrides
  reload = false,  // reload file and update cache
  bail = false     // return undefined on validation warnings
})

Supported files

  • "percy" entry in package.json
  • .percyrc YAML or JSON file
  • .percy.json JSON file
  • .percy.yaml or .percy.yml YAML file
  • .percy.js or percy.config.js file that exports an object

Extending config options

The .addSchema() function will add a sub-schema to the Percy configuration file which will be parsed and validated when PercyConfig.load() is called. See JSON schema for possible schema options.

import PercyConfig from '@percy/config'

PercyConfig.addSchema({ propertyName: JSONSchema })