1.0.0 • Published 3 years ago
@jochlain/babel-plugin-yaml v1.0.0
@jochlain/babel-plugin-yaml
Babel plugin to transform YAML require to JSON
Inspired from NPM package babel-plugin-convert-to-json
Installation
npm i @jochlain/babel-plugin-yaml
Configuration
Via .babelrc.js
(recommended)
module.exports = {
// ...
"plugins": [
// ...
"@jochlain/babel-plugin-yaml"
]
}
Via cli
babel --plugins @jochlain/babel-plugin-yaml index.js
Via Node
require('@babel/core').transform('some code', {
plugins: ['@jochlain/babel-plugin-yaml'],
});
Usage
# ./example.yaml
hello: "world"
// ./index.js
import yaml from "./example.yaml";
// or
const yaml = require('./example.yaml');
console.log(yaml.hello); // => "world"
1.0.0
3 years ago