The Vite manifest is generated when you run npm run dev or npm run build, and it's used by Vite to map the module ids to the actual file paths. This file is typically not meant to be persisted across development sessions because it represents the current state of your build.
However, if you want to keep the manifest file even after you stop the development server, you could consider building your project using npm run build. This will generate a dist directory (or whatever your output directory is configured to be) with all the assets for your project, including the manifest.json file. This is more of a production build, but you could technically serve this directory locally for development purposes.
Here's what you could do:
- Run the build command to generate the
distdirectory with the manifest:
npm run build
- Serve the
distdirectory using a static file server. You can use a package likeservefor this purpose:
npx serve dist
This will serve your built files on a local server, and you won't need to run npm run dev each time. However, keep in mind that this is not a replacement for the development server provided by Vite, as you won't have hot module replacement or other development features.
If you find yourself restarting the development server frequently and this is a hassle, you might want to look into why you need to restart so often. Ideally, Vite's development server should be able to reflect your changes without needing to restart frequently. If there's a specific issue causing you to restart, addressing that might be a better solution in the long run.