Vite plugin to import YAML files, with minimal dependencies
import {defineConfig} from "vite";
import {yamlPlugin} from "vite-yaml-plugin";
export default defineConfig({
plugins: [
yamlPlugin(),
],
});
import foo from "./foo.yaml";
match
: Regex to match the path against. Default:/\.(yaml|yml)$/i
.opts
: Options passed to js-yaml'sload
function.
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;
}