polen
Version:
A framework for delightful GraphQL developer portals
64 lines • 1.93 kB
TypeScript
import type { Plugin } from 'vite';
export interface Codec {
stringify(value: any): string;
parse(text: string): any;
}
export interface VitePluginJsonImportsOptions {
/**
* Use a custom codec.
*/
codec?: {
/**
* Import path for the custom codec to use in generated code.
*
* Must be a package name or use a path alias.
*
* Examples:
* - '@my-org/my-codec' (npm package)
* - '#utils/codec' (package subpath)
* - 'my-codec' (npm package)
* - '~/utils/codec' (if ~ is aliased in vite config)
*/
importPath: string;
/**
* Custom codec for validation and runtime parsing
* The codec.parse() is used at build time to validate the JSON
* The codec will be imported in the generated code for runtime parsing
* @default JSON
*/
validate?: Codec;
/**
* The export (its name) to import.
*
* @default 'default'
*/
importExport?: string;
};
filter?: {
/**
* Module types to process (the file extension without the dot).
* @default ['json']
*/
moduleTypes?: string[];
/**
* Picomatch patterns to include
* @default includes all files with configured extensions
*/
id?: {
include?: string | string[];
/**
* Picomatch patterns to exclude
* @default excludes node_modules and files with \0 prefix
*/
exclude?: string | string[];
};
};
/**
* Plugin name. Useful to customize if providing a custom codec e.g. `superjson`.
*
* @default 'json'
*/
name?: string;
}
export declare const create: (options?: VitePluginJsonImportsOptions) => Plugin;
//# sourceMappingURL=vite-plugin-json.d.ts.map