vite-yaml-plugin
v2.0.2
Published
Vite plugin to import YAML files
Readme
vite-yaml-plugin
Vite plugin to import YAML files, with minimal dependencies
Usage
vite.config.js
import {defineConfig} from "vite";
import {yamlPlugin} from "vite-yaml-plugin";
export default defineConfig({
plugins: [
yamlPlugin(),
],
});file.js
import foo from "./foo.yaml";Options
match: Regex to match the path against. Default:/\.(yaml|yml)$/i.opts: Options passed to js-yaml'sloadfunction.
Typescript
Add vite-yaml-plugin/types to your types in tsconfig.json:
{
"compilerOptions": {
"types": [
"vite-yaml-plugin/types"
]
}
}Alternatively, you can also add ambient type declarations:
declare module "*.yaml" {
const value: Record<string, any>;
export default value;
}
declare module "*.yml" {
const value: Record<string, any>;
export default value;
}