# vite-plugin-yaml2

> Vite plugin for convert YAML as JS export default

Latest version **1.1.5** (published 2023-02-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install vite-plugin-yaml2
pnpm add vite-plugin-yaml2
yarn add vite-plugin-yaml2
bun add vite-plugin-yaml2
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.5 |
| Published | 2023-02-01 |
| First published | 2022-05-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 42 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Zen |
| Maintainers | mzaini30 |
| Keywords | vite, vite-plugin, yaml |

## Links

- npm: https://www.npmjs.com/package/vite-plugin-yaml2
- Repository: https://github.com/mzaini30/vite-plugin-yaml2
- Homepage: https://github.com/mzaini30/vite-plugin-yaml2#readme
- Issues: https://github.com/mzaini30/vite-plugin-yaml2/issues
- npm.io page: https://npm.io/package/vite-plugin-yaml2

## Alternatives

- [monaco-yaml](https://npm.io/package/monaco-yaml.md) — 420.1K weekly downloads
- [@crewx/workflow](https://npm.io/package/@crewx/workflow.md) — 3.1K weekly downloads
- [yaml-cat](https://npm.io/package/yaml-cat.md) — 38 weekly downloads
- [nunjucks-in-yaml](https://npm.io/package/nunjucks-in-yaml.md) — 9 weekly downloads
- [shopify-symlinks](https://npm.io/package/shopify-symlinks.md) — 3 weekly downloads

## Recent versions

- 1.1.5 (latest) — 2023-02-01
- 1.1.4 — 2023-02-01
- 1.1.3 — 2023-01-30
- 1.1.2 — 2023-01-30
- 1.1.1 — 2023-01-30
- 1.1.0 — 2023-01-13
- 1.0.0 — 2022-06-16
- 0.2.4 — 2022-06-15
- 0.2.3 — 2022-06-15
- 0.2.2 — 2022-06-15
- 0.2.1 — 2022-06-15
- 0.2.0 — 2022-06-15
- 0.1.0 — 2022-06-12
- 0.0.4 — 2022-05-18
- 0.0.3 — 2022-05-18
- … 2 more at https://npm.io/package/vite-plugin-yaml2/versions

## README

# vite-plugin-yaml2

Vite plugin for convert YAML as JS export default

## Example

If we create YAML like this (`data.yml`):

```yaml
- name: Andre
  class: 1
- name: Agus
  class: 2
  hobby:
    - Swimming
    - Fishing
    - Sleep
```

We call it in `App.vue`:

```html
<script setup="">
  import data from "./data.yml";
</script>

<template>
  <p>{{ data }}</p>
</template>
```

This will return this:

```json
[
  {
    "name": "Andre",
    "class": 1
  },
  {
    "name": "Agus",
    "class": 2,
    "hobby": ["Swimming", "Fishing", "Sleep"]
  }
]
```

## Installation

```bash
npm i vite-plugin-yaml2
```

## Setup

Write this in `vite.config.ts`:

```typescript
import { defineConfig } from "vite";
import pluginYaml from "vite-plugin-yaml2";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [pluginYaml()],
});
```

## TypeScript Error

Add this inside `/src/vite-env.d.ts`:

```typescript
declare module "*.yaml" {
  const value: any;
  export default value;
}
declare module "*.yml" {
  const value: any;
  export default value;
}
```

[Join Community](https://zenzen.web.id/komunitas)

---
_Source: https://npm.io/package/vite-plugin-yaml2 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
