vaadin / flow

Vaadin Flow is a Java framework binding Vaadin web components to Java. This is part of Vaadin 10+.
Apache License 2.0
610 stars 167 forks source link

Vite Dev Server Port Specified in Config Overwritten #19069

Open tbwrigh opened 6 months ago

tbwrigh commented 6 months ago

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
mcollovati commented 3 months ago

There is a vaadin.devServerPort that seems could be used to set a custom port, but currently it does not seem to work.