Draft
Conversation
Co-authored-by: Sau1707 <83017316+Sau1707@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] when running npm run dev the vite server does not starts import any port, in fact the http://localhost:5173/ is unreachable. How to fix that?
Fix Vite dev server not starting on port 5173
Oct 1, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When running
npm run dev, the Vite development server was not accessible athttp://localhost:5173/. The root URL returned a 404 error, making it seem like the server wasn't running at all, even though the@crxjs/vite-pluginwas successfully building the extension.This issue occurs because
@crxjs/vite-pluginis specifically designed for Chrome extension development and doesn't configure a traditional web server by default. While the plugin does start Vite in watch mode to build the extension, it doesn't expose the typical development server interface that developers expect.Solution
Added explicit server configuration to
vite.config.jsto ensure the Vite dev server runs properly on port 5173:Created a user-friendly
index.htmllanding page that serves as a development dashboard, providing:Updated the README to clarify that the dev server is accessible and how to use it during development.
Result
✅ Dev server now properly starts and is accessible at
http://localhost:5173/✅ Root URL displays a helpful development dashboard
✅ Extension components can be previewed directly in the browser (e.g.,
http://localhost:5173/src/popup/popup.html)✅ Extension still builds correctly to the
dist/folder for Chrome✅ HMR functionality is fully preserved
Screenshots
Development Server Dashboard:
The landing page provides clear instructions and links to extension components.
Popup Component Preview:
Individual extension components can now be previewed directly in the browser with HMR support.
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.