Skip to content

Commit

Permalink
refactor: minor
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Apr 9, 2024
1 parent ced97d9 commit dba45bc
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions examples/workerd/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,15 @@ export function vitePluginWorkerd(pluginOptions: WorkerdPluginOptions): Plugin {
},

configureServer(server) {
return async () => {
const devEnv = server.environments["workerd"] as WorkerdDevEnvironment;
server.middlewares.use(
createMiddleware(
(ctx) => devEnv.api.dispatchFetch(pluginOptions.entry, ctx.request),
{
alwaysCallNext: false,
},
),
);
const devEnv = server.environments["workerd"] as WorkerdDevEnvironment;
const nodeMiddleware = createMiddleware(
(ctx) => devEnv.api.dispatchFetch(pluginOptions.entry, ctx.request),
{
alwaysCallNext: false,
},
);
return () => {
server.middlewares.use(nodeMiddleware);
};
},
};
Expand Down

0 comments on commit dba45bc

Please sign in to comment.