unplugin-yaml

Allow importing YAML files as JSON or Strings
440,181 6
Install
npm install unplugin-yaml
Latest Version:4.3.1
Vue:3
License:MIT
Last Updated:Oct 21, 2026
Links: GitHub  ·  npm
Maintainer: luxass

unplugin-yaml

npm version npm downloads

Allow import YAML file for Vite, Webpack, Rollup and esbuild. With TypeScript support. Powered by unplugin.

Install

npm i -D unplugin-yaml

Usage

[!TIP] You can view all examples here.

// vite.config.ts
import YAMLPlugin from "unplugin-yaml/vite";

export default defineConfig({
  plugins: [YAMLPlugin({/* options */})],
});

// rollup.config.js
import YAMLPlugin from "unplugin-yaml/rollup";

export default {
  plugins: [YAMLPlugin({/* options */})],
};

// webpack.config.js
module.exports = {
  /* ... */
  plugins: [require("unplugin-yaml/webpack").default({/* options */})],
};

// nuxt.config.js
export default defineNuxtConfig({
  modules: [["unplugin-yaml/nuxt", {/* options */}]],
});

// astro.config.mjs
import { defineConfig } from "astro/config";
import YAMLPlugin from "unplugin-yaml/astro";

// https://astro.build/config
export default defineConfig({
  integrations: [YAMLPlugin({/* options */})],
});

// esbuild.config.js
import { build } from "esbuild";
import YAMLPlugin from "unplugin-yaml/esbuild";

build({
  /* ... */
  plugins: [YAMLPlugin({/* options */})],
});

// rspack.config.mjs
import rspack from "@rspack/core";
import YAMLPlugin from "unplugin-yaml/rspack";

/** @type {import('@rspack/core').Configuration} */
export default {
  plugins: [
    new rspack.HtmlRspackPlugin({
      template: "./index.html",
    }),
    YAMLPlugin(),
  ],
};

// rolldown.config.js
import { defineConfig } from "rolldown";
import YAMLPlugin from "unplugin-yaml/rolldown";

export default defineConfig({
  input: "./index.js",
  plugins: [YAMLPlugin({/* options */})],
});

Configuration

YAMLPlugin({
  include: [
    /\.yamlcustom$/, // .yamlcustom
  ],
  parserOptions: {
    // see yaml load options
  },
});

TypeScript

If you are using TypeScript, you need to add the following to your tsconfig.json file:

{
  "compilerOptions": {
    "types": ["unplugin-yaml/types"]
  }
}

📄 License

Published under MIT License.

Related Packages

@relevate/unplugin-poolster

Run Poolster OpenAPI generation from Vite, Rollup, webpack, esbuild, Rspack, Rol...

197 3
unplugin-vue-named-export

Named export for Vue SFC.

9,463 22
unplugin-strip-whitespace

Unplugin to strip inter-node whitespace in Astro and Svelte templates (Vite/Roll...

787 0
unplugin-auto-import

Register global imports on demand for Vite and Webpack

40,166,207 3,799

Version History

Version Released License
4.3.1 MIT
4.3.0 MIT
4.2.1 MIT
4.2.0 MIT
4.1.0 MIT