vite-plugin-indexify
Version:
Generate jsons that index all or some files output by vite.
37 lines (36 loc) • 1.28 kB
TypeScript
/**
* The plugin-specific options for indexify.
*
* @example
* ```js
* indexify([{
* directory: 'posts',
* indexFileName: 'posts.json',
* include: '.*\.md$',
* exclude: '.*\.draft.md$'
* recurse: true
* },{
* directory: 'images/fetchable-images',
* indexFileName: 'images.json',
* recurse: true,
* recurseFlat: true
* }])
* ```
*/
export type IndexifyOptions = Array<IndexifyDirectoryOptions>;
export interface IndexifyDirectoryOptions {
/** The directory, relative to 'public', to indexify. */
directory: string;
/** The output file name. Defaults to 'index.json' */
indexFileName?: string;
/** Only filenames matching this pattern will be indexified. Defaults to all. */
include?: RegExp;
/** Filenames matching this pattern will not be indexified. Defaults to none. */
exclude?: RegExp;
/** Whether to include directories in the index.json */
includeSubdirs?: boolean;
/** Whether to recurse into and indexify subdirectories. They will have the same indexFileName. */
recurse?: boolean;
}
/** Gets the indexifying function, configured based on the options. */
export default function getIndexifier(indexifyOptionsParam?: IndexifyOptions, outDir?: string): () => void;