@redwoodjs/sdk
Version:
Build fast, server-driven webapps on Cloudflare with SSR, RSC, and realtime
24 lines (23 loc) • 673 B
JavaScript
export const asyncSetupPlugin = ({ setup, }) => {
let taskPromise = Promise.resolve(null);
return [
{
name: "rwsdk:async-setup-serve",
apply: "serve",
configureServer(server) {
taskPromise = setup({ command: "serve" });
server.middlewares.use(async (_req, _res, next) => {
await taskPromise;
next();
});
},
},
{
name: "rwsdk:async-setup-build",
apply: "build",
async buildStart() {
await setup({ command: "build" });
},
},
];
};