Skip to content

Commit

Permalink
feat!: vite dev default port is now 5173 (#8148)
Browse files Browse the repository at this point in the history
  • Loading branch information
patak-dev committed May 12, 2022
1 parent 02ff481 commit 1cc2e2d
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 30 deletions.
4 changes: 2 additions & 2 deletions docs/config/index.md
Expand Up @@ -477,7 +477,7 @@ export default defineConfig(({ command, mode }) => {
### server.port

- **Type:** `number`
- **Default:** `3000`
- **Default:** `5173`

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.

Expand Down Expand Up @@ -551,7 +551,7 @@ export default defineConfig(({ command, mode }) => {
},
// Proxying websockets or socket.io
'/socket.io': {
target: 'ws://localhost:3000',
target: 'ws://localhost:5173',
ws: true
}
}
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/api-plugin.md
Expand Up @@ -11,7 +11,7 @@ Vite strives to offer established patterns out of the box, so before creating a
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).

::: tip
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).
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).
![vite-plugin-inspect](/images/vite-plugin-inspect.png)
:::

Expand Down
6 changes: 3 additions & 3 deletions docs/guide/backend-integration.md
Expand Up @@ -29,11 +29,11 @@ If you need a custom integration, you can follow the steps in this guide to conf
import 'vite/modulepreload-polyfill'
```

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

```html
<!-- if development -->
<script type="module" src="http://localhost:3000/main.js"></script>
<script type="module" src="http://localhost:5173/main.js"></script>
```

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

```html
<script type="module">
import RefreshRuntime from 'http://localhost:3000/@react-refresh'
import RefreshRuntime from 'http://localhost:5173/@react-refresh'
RefreshRuntime.injectIntoGlobalHook(window)
window.$RefreshReg$ = () => {}
window.$RefreshSig$ = () => (type) => type
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/ssr.md
Expand Up @@ -89,7 +89,7 @@ async function createServer() {
// serve index.html - we will tackle this next
})

app.listen(3000)
app.listen(5173)
}

createServer()
Expand Down
2 changes: 1 addition & 1 deletion packages/vite/src/node/server/index.ts
Expand Up @@ -571,7 +571,7 @@ async function startServer(
}

const options = server.config.server
const port = inlinePort ?? options.port ?? 3000
const port = inlinePort ?? options.port ?? 5173
const hostname = resolveHostname(options.host)

const protocol = options.https ? 'https' : 'http'
Expand Down
6 changes: 3 additions & 3 deletions packages/vite/src/node/server/middlewares/indexHtml.ts
Expand Up @@ -92,10 +92,10 @@ const processNodeUrl = (
originalUrl !== '/' &&
htmlPath === '/index.html'
) {
// #3230 if some request url (localhost:3000/a/b) return to fallback html, the relative assets
// #3230 if some request url (localhost:5173/a/b) return to fallback html, the relative assets
// path will add `/a/` prefix, it will caused 404.
// rewrite before `./index.js` -> `localhost:3000/a/index.js`.
// rewrite after `../index.js` -> `localhost:3000/index.js`.
// rewrite before `./index.js` -> `localhost:5173/a/index.js`.
// rewrite after `../index.js` -> `localhost:5173/index.js`.
s.overwrite(
node.value!.loc.start.offset,
node.value!.loc.end.offset,
Expand Down
2 changes: 1 addition & 1 deletion playground/cli-module/__tests__/serve.ts
Expand Up @@ -94,7 +94,7 @@ export async function serve() {
}

try {
await startedOnPort(serverProcess, port, 3000)
await startedOnPort(serverProcess, port, 5173)
return { close }
} catch (e) {
collectErrorStreams('server', e)
Expand Down
4 changes: 2 additions & 2 deletions playground/cli/__tests__/serve.ts
Expand Up @@ -79,7 +79,7 @@ export async function serve() {
const timeoutError = `server process still alive after 3s`
try {
await killProcess(serverProcess)
await resolvedOrTimeout(serverProcess, 3000, timeoutError)
await resolvedOrTimeout(serverProcess, 5173, timeoutError)
} catch (e) {
if (e === timeoutError || (!serverProcess.killed && !isWindows)) {
collectErrorStreams('server', e)
Expand All @@ -94,7 +94,7 @@ export async function serve() {
}

try {
await startedOnPort(serverProcess, port, 3000)
await startedOnPort(serverProcess, port, 5173)
return { close }
} catch (e) {
collectErrorStreams('server', e)
Expand Down
4 changes: 2 additions & 2 deletions playground/json/server.js
Expand Up @@ -78,8 +78,8 @@ async function createServer(

if (!isTest) {
createServer().then(({ app }) =>
app.listen(3000, () => {
console.log('http://localhost:3000')
app.listen(5173, () => {
console.log('http://localhost:5173')
})
)
}
Expand Down
4 changes: 2 additions & 2 deletions playground/optimize-missing-deps/server.js
Expand Up @@ -51,8 +51,8 @@ async function createServer(root = process.cwd()) {

if (!isTest) {
createServer().then(({ app }) =>
app.listen(3000, () => {
console.log('http://localhost:3000')
app.listen(5173, () => {
console.log('http://localhost:5173')
})
)
}
Expand Down
4 changes: 2 additions & 2 deletions playground/ssr-deps/server.js
Expand Up @@ -58,8 +58,8 @@ async function createServer(

if (!isTest) {
createServer().then(({ app }) =>
app.listen(3000, () => {
console.log('http://localhost:3000')
app.listen(5173, () => {
console.log('http://localhost:5173')
})
)
}
Expand Down
4 changes: 2 additions & 2 deletions playground/ssr-html/server.js
Expand Up @@ -88,8 +88,8 @@ async function createServer(

if (!isTest) {
createServer().then(({ app }) =>
app.listen(3000, () => {
console.log('http://localhost:3000')
app.listen(5173, () => {
console.log('http://localhost:5173')
})
)
}
Expand Down
4 changes: 2 additions & 2 deletions playground/ssr-pug/server.js
Expand Up @@ -66,8 +66,8 @@ async function createServer(

if (!isTest) {
createServer().then(({ app }) =>
app.listen(3000, () => {
console.log('http://localhost:3000')
app.listen(5173, () => {
console.log('http://localhost:5173')
})
)
}
Expand Down
4 changes: 2 additions & 2 deletions playground/ssr-react/server.js
Expand Up @@ -87,8 +87,8 @@ async function createServer(

if (!isTest) {
createServer().then(({ app }) =>
app.listen(3000, () => {
console.log('http://localhost:3000')
app.listen(5173, () => {
console.log('http://localhost:5173')
})
)
}
Expand Down
4 changes: 2 additions & 2 deletions playground/ssr-vue/server.js
Expand Up @@ -86,8 +86,8 @@ async function createServer(

if (!isTest) {
createServer().then(({ app }) =>
app.listen(3000, () => {
console.log('http://localhost:3000')
app.listen(5173, () => {
console.log('http://localhost:5173')
})
)
}
Expand Down
4 changes: 2 additions & 2 deletions playground/ssr-webworker/worker.js
Expand Up @@ -16,8 +16,8 @@ async function createServer() {

if (!isTest) {
createServer().then(({ app }) =>
app.listen(3000, () => {
console.log('http://localhost:3000')
app.listen(5173, () => {
console.log('http://localhost:5173')
})
)
}
Expand Down

0 comments on commit 1cc2e2d

Please sign in to comment.