esbuild-yaml
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

esbuild-yaml

npm version npm downloads

This plugin allows you to import YAML files with ESBUILD

📦 Installation

npm install --save-dev esbuild-yaml

📚 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.

Package Sidebar

Install

npm i esbuild-yaml

Weekly Downloads

582

Version

1.1.1

License

MIT

Unpacked Size

9.08 kB

Total Files

8

Last publish

Collaborators

  • luxass