1.0.1 • Published 9 months ago

unplugin-yaml v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

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 */
    }),
  ],
});

// farm.config.ts
import { defineConfig } from "@farmfe/core";
import vue from "@vitejs/plugin-vue";
import YAMLPlugin from "unplugin-yaml/farm";

export default defineConfig({
  vitePlugins: [
    vue(),
  ],
  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 js-yaml load options
  }

});

TypeScript

!IMPORTANT If you are using JSR, you need to copy the yaml.d.ts file into your project. jsr doesn't support augmentation on global types.

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.

1.0.1

9 months ago

1.0.0

9 months ago

0.6.0

10 months ago

0.3.0

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.5.0

12 months ago

0.4.0

12 months ago

0.2.2

1 year ago

0.5.2

12 months ago

0.5.1

12 months ago

0.1.0

2 years ago

0.1.1

2 years ago

0.0.2

4 years ago

0.0.1

4 years ago