Home

Awesome

yaml.macro

A Babel macro for loading YAML files.

npm install --save-dev yaml.macro

Source:

# file.yaml
- YAML file
- with: some contents
import yaml from 'yaml.macro'

const foo = yaml('./file.yaml')

Result:

const foo = ['YAML file', { with: 'some contents' }];

yaml(path: string, options?: {}): any

Relative path values should start with .. Internally, the macro uses yaml and supports its parser options as a second argument. As the macro arguments are evaluated at build time, they should not be dynamically modified by preceding code.

Multiple calls to load the same YAML file will not be cached.