TypeScript icon, indicating that this package has built-in type declarations

1.4.5 • Public • Published


A small vite plugin to list your directory contents.

Why? In development mode, vite will allow you to have as many inputs as you want, simply run vite . and the current folder will be served up. Clicking any .html files will be compiled by vite (vited?). So, rather than manually type in the paths to all your inputs, this will list all your files so you can click them with ease. Like the good 'ol Index Of / days.

How to use:

  1. npm i vite vite-plugin-list-directory-contents
  2. create a vite.config.ts (or .js) like this:
import { defineConfig } from "vite";
import { directoryPlugin } from "vite-plugin-list-directory-contents";

export default defineConfig({
  plugins: [directoryPlugin({ baseDir: __dirname })],
  1. The first time it's run, the plugin will create an index.html for you in your baseDir. You can put anything in this file, and it will be processed by vite, but the important part is the {%DIRECTORY%} template tag that will be replaced with the directory listing.

  2. go ahead and run vite from your cli, or set a "dev": "vite" in your `package.json scripts"


directoryPlugin has two arguments:

  1. baseDir - where do you want to serve the files up from? __dirname is a good choice, but you can set to a subfolder.
  2. filterList - an array of files to filter out. Defaults to ['.DS_Store', 'package.json', 'package-lock.json', 'node_modules', '.parcelrc', '.parcel-cache', 'dist', 'packages', '.git', '.eslintrc', '.gitignore', '.npmrc', 'tsconfig.json', 'vite.config.ts', '.env', 'development.env', 'production.env']


This plugin is only meant to run in "serve" mode (development). It will be ignored on build.


You should note that anytime you create a local server listing directory files on your computer, anyone on your local network could find the port and visit your application. This is great, because you can visit your apps from your phone.

This plugin doesn't allow any access to files that vite doesn't already do, but it does list your files, so don't run it on any folders you don't want opened up to your local network.

Vite does already deny common files like .env:


Edit plugin.ts, then run npm run build to build a copy. Edits welcome :)

You can run npm run demo to test things out with some code in the /demo dir.




Package Sidebar


npm i vite-plugin-list-directory-contents

Weekly Downloads






Unpacked Size

7.93 MB

Total Files


Last publish


  • wesbos