Skip to content

Commit 1cc2e2d

Browse files
authored
feat!: vite dev default port is now 5173 (#8148)
1 parent 02ff481 commit 1cc2e2d

File tree

16 files changed

+30
-30
lines changed

16 files changed

+30
-30
lines changed

docs/config/index.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ export default defineConfig(({ command, mode }) => {
477477
### server.port
478478

479479
- **Type:** `number`
480-
- **Default:** `3000`
480+
- **Default:** `5173`
481481

482482
Specify server port. Note if the port is already being used, Vite will automatically try the next available port so this may not be the actual port the server ends up listening on.
483483

@@ -551,7 +551,7 @@ export default defineConfig(({ command, mode }) => {
551551
},
552552
// Proxying websockets or socket.io
553553
'/socket.io': {
554-
target: 'ws://localhost:3000',
554+
target: 'ws://localhost:5173',
555555
ws: true
556556
}
557557
}

docs/guide/api-plugin.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Vite strives to offer established patterns out of the box, so before creating a
1111
When creating a plugin, you can inline it in your `vite.config.js`. There is no need to create a new package for it. Once you see that a plugin was useful in your projects, consider sharing it to help others [in the ecosystem](https://chat.vitejs.dev).
1212

1313
::: tip
14-
When learning, debugging, or authoring plugins we suggest including [vite-plugin-inspect](https://github.com/antfu/vite-plugin-inspect) in your project. It allows you to inspect the intermediate state of Vite plugins. After installing, you can visit `localhost:3000/__inspect/` to inspect the modules and transformation stack of your project. Check out install instructions in the [vite-plugin-inspect docs](https://github.com/antfu/vite-plugin-inspect).
14+
When learning, debugging, or authoring plugins we suggest including [vite-plugin-inspect](https://github.com/antfu/vite-plugin-inspect) in your project. It allows you to inspect the intermediate state of Vite plugins. After installing, you can visit `localhost:5173/__inspect/` to inspect the modules and transformation stack of your project. Check out install instructions in the [vite-plugin-inspect docs](https://github.com/antfu/vite-plugin-inspect).
1515
![vite-plugin-inspect](/images/vite-plugin-inspect.png)
1616
:::
1717

docs/guide/backend-integration.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ If you need a custom integration, you can follow the steps in this guide to conf
2929
import 'vite/modulepreload-polyfill'
3030
```
3131

32-
2. For development, inject the following in your server's HTML template (substitute `http://localhost:3000` with the local URL Vite is running at):
32+
2. For development, inject the following in your server's HTML template (substitute `http://localhost:5173` with the local URL Vite is running at):
3333

3434
```html
3535
<!-- if development -->
36-
<script type="module" src="http://localhost:3000/main.js"></script>
36+
<script type="module" src="http://localhost:5173/main.js"></script>
3737
```
3838

3939
In order to properly serve assets, you have two options:
@@ -47,7 +47,7 @@ If you need a custom integration, you can follow the steps in this guide to conf
4747

4848
```html
4949
<script type="module">
50-
import RefreshRuntime from 'http://localhost:3000/@react-refresh'
50+
import RefreshRuntime from 'http://localhost:5173/@react-refresh'
5151
RefreshRuntime.injectIntoGlobalHook(window)
5252
window.$RefreshReg$ = () => {}
5353
window.$RefreshSig$ = () => (type) => type

docs/guide/ssr.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ async function createServer() {
8989
// serve index.html - we will tackle this next
9090
})
9191

92-
app.listen(3000)
92+
app.listen(5173)
9393
}
9494

9595
createServer()

packages/vite/src/node/server/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ async function startServer(
571571
}
572572

573573
const options = server.config.server
574-
const port = inlinePort ?? options.port ?? 3000
574+
const port = inlinePort ?? options.port ?? 5173
575575
const hostname = resolveHostname(options.host)
576576

577577
const protocol = options.https ? 'https' : 'http'

packages/vite/src/node/server/middlewares/indexHtml.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ const processNodeUrl = (
9292
originalUrl !== '/' &&
9393
htmlPath === '/index.html'
9494
) {
95-
// #3230 if some request url (localhost:3000/a/b) return to fallback html, the relative assets
95+
// #3230 if some request url (localhost:5173/a/b) return to fallback html, the relative assets
9696
// path will add `/a/` prefix, it will caused 404.
97-
// rewrite before `./index.js` -> `localhost:3000/a/index.js`.
98-
// rewrite after `../index.js` -> `localhost:3000/index.js`.
97+
// rewrite before `./index.js` -> `localhost:5173/a/index.js`.
98+
// rewrite after `../index.js` -> `localhost:5173/index.js`.
9999
s.overwrite(
100100
node.value!.loc.start.offset,
101101
node.value!.loc.end.offset,

playground/cli-module/__tests__/serve.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export async function serve() {
9494
}
9595

9696
try {
97-
await startedOnPort(serverProcess, port, 3000)
97+
await startedOnPort(serverProcess, port, 5173)
9898
return { close }
9999
} catch (e) {
100100
collectErrorStreams('server', e)

playground/cli/__tests__/serve.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export async function serve() {
7979
const timeoutError = `server process still alive after 3s`
8080
try {
8181
await killProcess(serverProcess)
82-
await resolvedOrTimeout(serverProcess, 3000, timeoutError)
82+
await resolvedOrTimeout(serverProcess, 5173, timeoutError)
8383
} catch (e) {
8484
if (e === timeoutError || (!serverProcess.killed && !isWindows)) {
8585
collectErrorStreams('server', e)
@@ -94,7 +94,7 @@ export async function serve() {
9494
}
9595

9696
try {
97-
await startedOnPort(serverProcess, port, 3000)
97+
await startedOnPort(serverProcess, port, 5173)
9898
return { close }
9999
} catch (e) {
100100
collectErrorStreams('server', e)

playground/json/server.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ async function createServer(
7878

7979
if (!isTest) {
8080
createServer().then(({ app }) =>
81-
app.listen(3000, () => {
82-
console.log('http://localhost:3000')
81+
app.listen(5173, () => {
82+
console.log('http://localhost:5173')
8383
})
8484
)
8585
}

playground/optimize-missing-deps/server.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ async function createServer(root = process.cwd()) {
5151

5252
if (!isTest) {
5353
createServer().then(({ app }) =>
54-
app.listen(3000, () => {
55-
console.log('http://localhost:3000')
54+
app.listen(5173, () => {
55+
console.log('http://localhost:5173')
5656
})
5757
)
5858
}

playground/ssr-deps/server.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ async function createServer(
5858

5959
if (!isTest) {
6060
createServer().then(({ app }) =>
61-
app.listen(3000, () => {
62-
console.log('http://localhost:3000')
61+
app.listen(5173, () => {
62+
console.log('http://localhost:5173')
6363
})
6464
)
6565
}

playground/ssr-html/server.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ async function createServer(
8888

8989
if (!isTest) {
9090
createServer().then(({ app }) =>
91-
app.listen(3000, () => {
92-
console.log('http://localhost:3000')
91+
app.listen(5173, () => {
92+
console.log('http://localhost:5173')
9393
})
9494
)
9595
}

playground/ssr-pug/server.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ async function createServer(
6666

6767
if (!isTest) {
6868
createServer().then(({ app }) =>
69-
app.listen(3000, () => {
70-
console.log('http://localhost:3000')
69+
app.listen(5173, () => {
70+
console.log('http://localhost:5173')
7171
})
7272
)
7373
}

playground/ssr-react/server.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ async function createServer(
8787

8888
if (!isTest) {
8989
createServer().then(({ app }) =>
90-
app.listen(3000, () => {
91-
console.log('http://localhost:3000')
90+
app.listen(5173, () => {
91+
console.log('http://localhost:5173')
9292
})
9393
)
9494
}

playground/ssr-vue/server.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ async function createServer(
8686

8787
if (!isTest) {
8888
createServer().then(({ app }) =>
89-
app.listen(3000, () => {
90-
console.log('http://localhost:3000')
89+
app.listen(5173, () => {
90+
console.log('http://localhost:5173')
9191
})
9292
)
9393
}

playground/ssr-webworker/worker.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ async function createServer() {
1616

1717
if (!isTest) {
1818
createServer().then(({ app }) =>
19-
app.listen(3000, () => {
20-
console.log('http://localhost:3000')
19+
app.listen(5173, () => {
20+
console.log('http://localhost:5173')
2121
})
2222
)
2323
}

0 commit comments

Comments
 (0)