flow icon indicating copy to clipboard operation
flow copied to clipboard

Vite Dev Server Port Specified in Config Overwritten

Open tbwrigh opened this issue 3 months ago • 1 comments

Description of the bug

When I attempt to set a port for vite to start on using the vite.config.ts, it is overridden and vite starts on a random free port. This behavior can be tracked directly to the package com.vaadin.base.devserver in the class ViteHandler. Lines 93 and 94 of ViteHandler add the config and lines 95 and 96 following it overwrite the port.

Minimal reproducible example

Create a new vaadin project. In the config.vite.ts set the port by adding:

server {
    port: 8137
}

to the configuration. Build an exploded war, place the exploded war in a tomcat instance's webapps folder, observe, in the logs, that vite is started on a port other than 8137.

Expected behavior

Vite should be started on port specified in config.vite.ts is a port is specified.

Actual behavior

A random free port is chosen and that port is used.

Versions:

- Vaadin / Flow version: This dates back to at least Flow 23 and exists still in Flow 24
- Java version: Java 11 for Flow 23, Java 17 for Flow 24
- OS version: Windows 11, Windows 10, MacOS Sonoma 14.1.2
- Browser version (if applicable): N/A
- Application Server (if applicable): Tomcat 
- IDE (if applicable): N/A
- Development or production mode: Development
- Project from start.vaadin.com or activated in application: activated in application

tbwrigh avatar Mar 28 '24 14:03 tbwrigh