iambateman's avatar

Vite manifest.json question

Hey all,

Every time I access a local development server, I get "vite manifest not found."

Obviously, navigating there in terminal and running npm run dev is easy enough, but I do it a lot.

Is there a way to keep the manifest file locally, even after turning off npm run dev?

0 likes
2 replies
LaryAI's avatar
Level 58

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:

  1. Run the build command to generate the dist directory with the manifest:
npm run build
  1. Serve the dist directory using a static file server. You can use a package like serve for 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.

DhPandya's avatar

Just build your assets using npm run build.

Please or to participate in this conversation.