A Vite plugin (v2.2.0, stable, MIT) for serving arbitrary static files outside the standard `public` directory during local development. Unlike the built-in `publicDir` or `server.fs.allow`, this plugin supports regex-based URL-to-file mapping with flexible resolver functions, making it ideal for monorepos or projects where static files live in external directories. Requires Node >=20 and Vite >=5.0.0 <9.0.0. Note: does not handle production builds or serve.
npm install vite-plugin-serve-staticVerified import paths — ran on the pinned version, not inferred.
Configures serve-static plugin with two rules: static file via string path and dynamic file via resolver function.
Upgrade Node.js to 20 or later, or pin to v1.x.
Ensure Vite version is at least 5.0.0.
Migrate to ESM imports (no require()).
Use separate static file serving in production (e.g., nginx, express).
Use path.resolve or path.join with __dirname.
Switch to import statement or use dynamic import().
Update Vite to >=5.0.0 <9.0.0 (latest Vite 7 is supported).
Use absolute paths (e.g., path.resolve(__dirname, 'metadata.json')).