{"id":22721,"library":"vite-plugin-list-directory-contents","title":"Vite Plugin List Directory Contents","description":"A Vite plugin (v1.4.5) that generates a directory listing index page during development. Ideal for projects with multiple HTML entry points: it scans the base directory, filters common files (node_modules, .env, etc.), and injects the listing into a template using the {%DIRECTORY%} tag. Only active in serve mode; no-op on build. Minimal configuration: requires baseDir and optional filterList. Unlike general-purpose directory listing tools, it integrates seamlessly with Vite's dev server, allowing you to click through HTML files that are compiled on-the-fly. Maintained by Wes Bos, updated irregularly.","status":"active","version":"1.4.5","language":"javascript","source_language":"en","source_url":"https://github.com/wesbos/vite-plugin-list-directory-contents#readme","tags":["javascript","typescript"],"install":[{"cmd":"npm install vite-plugin-list-directory-contents","lang":"bash","label":"npm"},{"cmd":"yarn add vite-plugin-list-directory-contents","lang":"bash","label":"yarn"},{"cmd":"pnpm add vite-plugin-list-directory-contents","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency; plugin only works with Vite dev server","package":"vite","optional":false}],"imports":[{"note":"Named export only; default import is not available.","wrong":"import directoryPlugin from 'vite-plugin-list-directory-contents'","symbol":"directoryPlugin","correct":"import { directoryPlugin } from 'vite-plugin-list-directory-contents'"},{"note":"CommonJS destructuring required; plugin is not a default export.","wrong":"const directoryPlugin = require('vite-plugin-list-directory-contents')","symbol":"plugin (via require)","correct":"const { directoryPlugin } = require('vite-plugin-list-directory-contents')"},{"note":"TypeScript type for plugin options; useful for typed config.","wrong":"","symbol":"Config type","correct":"import type { DirectoryPluginOptions } from 'vite-plugin-list-directory-contents'"}],"quickstart":{"code":"// vite.config.ts\nimport { defineConfig } from 'vite';\nimport { directoryPlugin } from 'vite-plugin-list-directory-contents';\n\nexport default defineConfig({\n  plugins: [\n    directoryPlugin({ baseDir: __dirname }),\n  ],\n});","lang":"typescript","description":"Basic setup: import the plugin, pass baseDir, and use it in Vite config. The plugin will create an index.html with {%DIRECTORY%} tag."},"warnings":[{"fix":"No fix needed; it's by design. If you need directory listing in production, consider other solutions.","message":"Plugin only works in serve mode; it is a no-op during build.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"If you set a filterList, include all files you want to filter; defaults are not merged.","message":"The filterList default excludes many common files; custom filterList overrides defaults entirely.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure you have no custom index.html you want to preserve, or modify the template carefully.","message":"The plugin creates an index.html file in baseDir if it doesn't exist; this file is processed by Vite.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Run only on trusted networks or use Vite's server.host to restrict access.","message":"Security: listing directory contents exposes file structure to local network; Vite's server.fs.deny still applies.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Change to: import { directoryPlugin } from 'vite-plugin-list-directory-contents'","cause":"Using default import instead of named import.","error":"TypeError: directoryPlugin is not a function"},{"fix":"Add baseDir: __dirname (or your desired path) to the plugin options.","cause":"Missing baseDir in plugin options.","error":"Error: The argument 'baseDir' is required"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}