UNPKG

vite-plugin-indexify

Version:

Generate jsons that index all or some files output by vite.

42 lines (41 loc) 1.01 kB
import { type Plugin } from "vite"; import { type IndexifyOptions } from "./getIndexifier"; /** * Indexify creates index.jsons for your output directories. * * These files can list all or some of the files and/or folders in all or some of your directories. * * Indexify is passed a list of directories, relative to your output directory, that you want to create an index file for. The following is how it is used in a vite config. * * @example * ```js * plugins: [ * indexify([ * { * directory: "assets/posts", * includeSubdirs: true * recurse: true, * indexFileName: "posts.json" * }, * { * directory: "assets/images", * recurse: false, * } * ]), * ] * ``` * * Here is an example output, perhaps `assets/posts/posts.json`: * @example * ```json * [{ * "name": "post1.md", * "isDirectory": false * },{ * "name": "oldPosts", * "isDirectory": true * }] * ] * ``` */ export default function indexify(indexifyOptions?: IndexifyOptions): Plugin;