Object{}The config of DevServer can be modified through tools.devServer.
Modern.js does not directly use webpack-dev-server or @rspack/dev-server, but implement DevServer based on webpack-dev-middleware.
Deprecated: This configuration is deprecated, please use dev.server.compress instead.
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 {
tools: {
devServer: {
compress: false,
},
},
};Deprecated: This configuration is deprecated, please use dev.server.headers instead.
Record<string, string>undefinedAdds headers to all responses.
export default {
tools: {
devServer: {
headers: {
'X-Custom-Foo': 'bar',
},
},
},
};Deprecated: This configuration is deprecated, please use dev.server.historyApiFallback instead.
boolean | ConnectHistoryApiFallbackOptionsfalseThe index.html page will likely have to be served in place of any 404 responses. Enable devServer.historyApiFallback by setting it to true:
export default {
tools: {
devServer: {
historyApiFallback: true,
},
},
};For more options and information, see the connect-history-api-fallback documentation.
Deprecated: This configuration is deprecated, use dev.server.proxy instead.
ProxyOptions[] | Record<string, string | ProxyOptions>undefinedConfigure proxy rules for the dev server, and forward requests to the specified service.
export default {
tools: {
devServer: {
proxy: {
// http://localhost:8080/api -> https://example.com/api
// http://localhost:8080/api/foo -> https://example.com/api/foo
'/api': 'https://example.com/api',
},
},
},
};Deprecated: This configuration is deprecated, please use dev.server.watch instead.
booleantrueWhether to watch files change in directories such as mock/, server/, api/.