Closed aleyrizvi closed 6 months ago
This is intentional. The server.js
file is meant to be used in both dev and prod, and when deployed your dev deps (including any Vite plugins) used in your Vite config won't exist, so we can't read the Vite config in prod.
The only other way I guess is to bundle the server.js
script, but we chosed the current setup to not bundle it. Or we could respect the port only in dev, but I think it's also worth keeping the code simple for now.
This is intentional. The
server.js
file is meant to be used in both dev and prod, and when deployed your dev deps (including any Vite plugins) used in your Vite config won't exist, so we can't read the Vite config in prod.The only other way I guess is to bundle the
server.js
script, but we chosed the current setup to not bundle it. Or we could respect the port only in dev, but I think it's also worth keeping the code simple for now.
Thank you for the response.
What about something like: vite_port || process.env.PORT || 5173
?
How would we able to get vite_port
?
How would we able to get
vite_port
?
vite.config.server.port
I can update all the templates if you like and create a pull request.
@bluwy
Personally, I would replace hard coded value from DEFAULT_DEV_PORT
as well which is exported in vite/dist/node/constants.ts
however, it cannot be imported in server.js file
Hello,
server.js
line 7:This does not read configuration from vite.config.ts. The port defaults to
5173
even if we specify it in config file: