boolean | string | 'auto''/'Set the URL prefix of static assets during development.
assetPrefix will affect the URLs of most of the static assets, including JavaScript files, CSS files, images, videos, etc. If an incorrect value is specified, you'll receive 404 errors while loading these resources.
This config is only used during development. In the production build, please use the output.assetPrefix to set the URL prefix.
If assetPrefix is set to true, the URL prefix will be http://localhost:<port>/:
The resource URL loaded in the browser is as follows:
If assetPrefix is set to false or not set, / is used as the default value.
When the value of assetPrefix is a string type, the string will be used as a prefix and automatically appended to the static resource URL.
The resource URL loaded in the browser is as follows:
The resource URL loaded in the browser is as follows:
assetPrefix can be set to the following types of paths:
/assets/.It's not recommended to set assetPrefix as a relative path, such as './assets/'. This is because when assets are at different path depths, using relative paths may cause assets to load incorrectly.
publicPathThe functionality of dev.assetPrefix is basically the same as the output.publicPath config in Rspack.
The differences from the native configuration are as follows:
dev.assetPrefix only takes effect during development.dev.assetPrefix automatically appends a trailing / by default.dev.assetPrefix is written to the process.env.ASSET_PREFIX environment variable (can only be accessed in client code).