Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set vite (preview) production port?

I have been looking arround on how to set a production port for vite but I can't find way I have tried this vite js config

  server: {
    host: true,
  },
  preview:{
    port:5005
  }

but it seems like it can't work

like image 565
Ntwari Clarance Liberiste Avatar asked Sep 07 '25 20:09

Ntwari Clarance Liberiste


1 Answers

According to documentation this should work

export default defineConfig({
  server: {
    port: 3030
  },
  preview: {
    port: 8080
  }
})

But if it doesn't work add --port on preview command in package.json

"scripts": {
    "serve": "vite preview --port 6000"
  },
like image 153
Ntwari Clarance Liberiste Avatar answered Sep 11 '25 01:09

Ntwari Clarance Liberiste