undefined
server.open
is used to configure a set of page URLs that Rsbuild will automatically open in the browser after starting the server.
You can also use the --open option of Rsbuild CLI to open the pages. When using
server.open
and--open
at the same time,--open
takes precedence.
server.open
can be set to the following values.
http://localhost:<port>
. If server.host is configured, it defaults to http://<host>:<port>
.http://localhost:<port>/home
:The port number that Rsbuild server listens on may change. For example, if the port is in use, Rsbuild will automatically increment the port number until it finds an available port.
To avoid server.open
becoming invalid due to port changes, you can use one of the following methods:
<port>
placeholder to refer to the current port number. Rsbuild will replace the placeholder with the actual port number it is listening on.Rsbuild by default will open the page in the system's default browser.
On macOS, you can open the specified browser when dev server starts, by set environment variable BROWSER
, support values:
For example:
You can set BROWSER
in the local .env.local file, which helps avoid impacting other developers.
By using open.before
, you can trigger a callback function before opening the page.
When using open.before
, the page URLs can be configured via open.target
.