Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/luxass/esbuild-yaml
📦 A esbuild plugin that allow import of yaml files
https://github.com/luxass/esbuild-yaml
esbuild esbuild-plugin yaml
Last synced: about 1 month ago
JSON representation
📦 A esbuild plugin that allow import of yaml files
- Host: GitHub
- URL: https://github.com/luxass/esbuild-yaml
- Owner: luxass
- License: mit
- Created: 2022-07-21T22:01:29.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-14T01:05:51.000Z (about 1 month ago)
- Last Synced: 2024-08-14T03:38:27.763Z (about 1 month ago)
- Topics: esbuild, esbuild-plugin, yaml
- Language: TypeScript
- Homepage:
- Size: 301 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# esbuild-yaml
[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]> [!NOTE]
> If you are using different bundlers than esbuild, you could try [`unplugin-yaml`](https://github.com/luxass/unplugin-yaml)
> which supports all different kinds of bundlers, powered by unplugin.## 📦 Installation
```sh
npm install --save-dev esbuild-yaml esbuild
```## 📚 Usage
Add this to your build file
```js
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:
```json
{
"compilerOptions": {
"types": [
"esbuild-yaml/types"
]
}
}
```## 📖 Examples
```js
// build.js
import { build } from "esbuild";
import { YAMLPlugin } from "esbuild-yaml";const yourConfig = {};
build({
...yourConfig,
plugins: [
YAMLPlugin()
]
});
``````yaml
# config.yaml
name: esbuild-yamlversion: 1.0.0
``````ts
// index.tsimport config from "./config.yaml"; // this will be converted to a JSON object
import configRaw from "./config.yaml?raw"; // this will be the raw YAML stringconsole.log(config); // { name: "esbuild-yaml", version: "1.0.0" }
console.log(configRaw); // name: esbuild-yaml\nversion: 1.0.0
```## 📄 License
Published under [MIT License](./LICENSE).
[npm-version-src]: https://img.shields.io/npm/v/esbuild-yaml?style=flat&colorA=18181B&colorB=4169E1
[npm-version-href]: https://npmjs.com/package/esbuild-yaml
[npm-downloads-src]: https://img.shields.io/npm/dm/esbuild-yaml?style=flat&colorA=18181B&colorB=4169E1
[npm-downloads-href]: https://npmjs.com/package/esbuild-yaml