Home > @lynx-js/rspeedy > Dev > assetPrefix
The Dev.assetPrefix is used to set the URL prefix for static assets during development.
Signature:
The functionality of Dev.assetPrefix is basically the same as the output.publicPath config in Rspack. With the following differences:
dev.assetPrefix
only takes effect during development.
dev.assetPrefix
automatically appends a trailing /
by default.
The value of dev.assetPrefix
is written to the process.env.ASSET_PREFIX
environment variable.
If dev.assetPrefix
is set to true, the URL prefix will be http://<host>:<port>/
:
If dev.assetPrefix
is set to a string, the value will be used as a prefix and automatically appended to the static resource URL.
The port number that Rspeedy server listens on may change. For example, if the port is in use, Rspeedy will automatically increment the port number until it finds an available port.
To avoid dev.assetPrefix
becoming invalid due to port changes, you can use one of the following methods:
Enable server.strictPort
.
Use the <port>
placeholder to refer to the current port number. Rspeedy will replace the placeholder with the actual port number it is listening on.