Object{}The config of DevServer can be modified through dev.server.
booleantrueWhether to enable gzip compression for served static assets.
If you want to disable the gzip compression, you can set compress to false:
export default {
dev: {
server: {
compress: false,
},
},
};For more details, please refer to the Rsbuild - server.compress documentation.
Record<string, string>undefinedAdds headers to all responses.
export default {
dev: {
server: {
headers: {
'X-Custom-Foo': 'bar',
},
},
},
};For more details, please refer to the Rsbuild - server.headers documentation.
boolean | ConnectHistoryApiFallbackOptionsfalseThe index.html page will likely have to be served in place of any 404 responses. Enable dev.server.historyApiFallback by setting it to true:
export default {
dev: {
server: {
historyApiFallback: true,
},
},
};For more configuration options, please refer to the Rsbuild - server.historyApiFallback documentation.
booleantrueWhether to watch files change in directories such as mock/, server/, api/.
For more details, please refer to the Rsbuild - dev.watchFiles documentation.
boolean | import('cors').CorsOptionsConfigure CORS (Cross-Origin Resource Sharing) for the development server.
The default configuration for cors in Modern.js follows Rsbuild's defaults:
const defaultAllowedOrigins =
/^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/;
const defaultOptions = {
// Default allowed:
// - localhost
// - 127.0.0.1
// - [::1]
origin: defaultAllowedOrigins,
};For more configuration options and detailed usage, please refer to the Rsbuild - server.cors documentation.
ProxyOptions[] | Record<string, string | ProxyOptions>undefinedConfigure proxy rules for the dev server, and forward requests to the specified service.
export default {
dev: {
server: {
proxy: {
// http://localhost:8080/api -> https://example.com/api
// http://localhost:8080/api/foo -> https://example.com/api/foo
'/api': 'https://example.com/api',
},
},
},
};
This option is the same as Rsbuild's server.proxy option, see Rsbuild - server.proxy for detailed usage.