Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/luxass/unplugin-yaml
📦 A unplugin that allow import of yaml files
https://github.com/luxass/unplugin-yaml
esbuild rollup unplugin vite webpack yaml
Last synced: 6 days ago
JSON representation
📦 A unplugin that allow import of yaml files
- Host: GitHub
- URL: https://github.com/luxass/unplugin-yaml
- Owner: luxass
- License: mit
- Created: 2023-12-12T18:58:14.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-05T04:50:16.000Z (11 days ago)
- Last Synced: 2025-02-07T13:48:21.641Z (9 days ago)
- Topics: esbuild, rollup, unplugin, vite, webpack, yaml
- Language: TypeScript
- Homepage:
- Size: 1.77 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# unplugin-yaml
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]Allow import YAML file for Vite, Webpack, Rollup and esbuild. With TypeScript support. Powered by [unplugin](https://github.com/unjs/unplugin).
## Install
```bash
npm i -D unplugin-yaml
```## Usage
> [!TIP]
> You can view all examples [here](./examples).Vite
```ts
// vite.config.ts
import YAMLPlugin from "unplugin-yaml/vite";export default defineConfig({
plugins: [
YAMLPlugin({ /* options */ }),
],
});
```
Rollup
```ts
// rollup.config.js
import YAMLPlugin from "unplugin-yaml/rollup";export default {
plugins: [
YAMLPlugin({ /* options */ }),
],
};
```
Webpack
```ts
// webpack.config.js
module.exports = {
/* ... */
plugins: [
require("unplugin-yaml/webpack").default({ /* options */ }),
],
};
```
Nuxt
```ts
// nuxt.config.js
export default defineNuxtConfig({
modules: [
["unplugin-yaml/nuxt", { /* options */ }]
],
});
```
Astro
```ts
// 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
```ts
// esbuild.config.js
import { build } from "esbuild";
import YAMLPlugin from "unplugin-yaml/esbuild";build({
/* ... */
plugins: [
YAMLPlugin({
/* options */
}),
],
});
```
Farm
```ts
// 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
```ts
// 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 (Experimental)
```ts
// rolldown.config.js
import { defineConfig } from "rolldown";
import YAMLPlugin from "unplugin-yaml/rolldown";export default defineConfig({
input: "./index.js",
plugins: [
YAMLPlugin({
/* options */
}),
],
});
```
## Configuration
```ts
YAMLPlugin({
include: [
/\.yamlcustom$/, // .yamlcustom
],
parserOptions: {
// see 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:
```json
{
"compilerOptions": {
"types": [
"unplugin-yaml/types"
]
}
}
```## 📄 License
Published under [MIT License](./LICENSE).
[npm-version-src]: https://img.shields.io/npm/v/unplugin-yaml?style=flat&colorA=18181B&colorB=4169E1
[npm-version-href]: https://npmjs.com/package/unplugin-yaml
[npm-downloads-src]: https://img.shields.io/npm/dm/unplugin-yaml?style=flat&colorA=18181B&colorB=4169E1
[npm-downloads-href]: https://npmjs.com/package/unplugin-yaml