2.0.0 • Published 9 months ago
esbuild-yaml v2.0.0
esbuild-yaml
!NOTE If you are using different bundlers than esbuild, you could try
unplugin-yamlwhich supports all different kinds of bundlers, powered by unplugin.
📦 Installation
npm install --save-dev esbuild-yaml esbuild📚 Usage
Add this to your build file
import { build } from "esbuild";
import { YAMLPlugin } from "esbuild-yaml";
const yourConfig = {};
build({
...yourConfig,
plugins: [
YAMLPlugin()
]
});TypeScript
If you are using TypeScript, you need to add the following to your tsconfig.json file:
{
"compilerOptions": {
"types": [
"esbuild-yaml/types"
]
}
}📖 Examples
// build.js
import { build } from "esbuild";
import { YAMLPlugin } from "esbuild-yaml";
const yourConfig = {};
build({
...yourConfig,
plugins: [
YAMLPlugin()
]
});# config.yaml
name: esbuild-yaml
version: 1.0.0// index.ts
import config from "./config.yaml"; // this will be converted to a JSON object
import configRaw from "./config.yaml?raw"; // this will be the raw YAML string
console.log(config); // { name: "esbuild-yaml", version: "1.0.0" }
console.log(configRaw); // name: esbuild-yaml\nversion: 1.0.0📄 License
Published under MIT License.