type SetupMiddlewaresServer = {
sockWrite: (
type: string,
data?: string | boolean | Record<string, any>,
) => void;
environments: {
[name: string]: {
/**
* Get stats info about current environment.
*/
getStats: () => Promise<Stats>;
/**
* Load and execute stats bundle in server.
*
* @param entryName - relate to Rsbuild's `source.entry`
* @returns the return value of entry module.
*/
loadBundle: <T = unknown>(entryName: string) => Promise<T>;
/**
* Get the compiled HTML template.
*/
getTransformedHtml: (entryName: string) => Promise<string>;
};
};
};
type SetupMiddlewares = Array<
(
middlewares: {
unshift: (...handlers: RequestHandler[]) => void;
push: (...handlers: RequestHandler[]) => void;
},
server: SetupMiddlewaresServer,
) => void
>;undefinedProvides the ability to execute a custom function and apply custom middlewares.
The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to Rsbuild - dev.setupMiddlewares.