MCPcopy Create free account
hub / github.com/Borrus-sudo/tinypages / createDevServer

Function createDevServer

packages/vite/src/node/dev.ts:11–45  ·  view source on GitHub ↗
(
  config: TinyPagesConfig,
  source: string
)

Source from the content-addressed store, hash-verified

9import kleur from "kleur";
10
11export async function createDevServer(
12 config: TinyPagesConfig,
13 source: string
14): Promise<ViteDevServer> {
15 const [context, vite] = await createDevContext(
16 config,
17 createDevPlugins,
18 source
19 );
20 const app = polka();
21
22 if ((config.middlewares.pre?.length ?? -1) > 0)
23 app.use(config.middlewares.pre);
24
25 app.use(vite.middlewares);
26 app.use(devtoolsMiddleware());
27 app.use(...createMiddlewares());
28
29 if ((config.middlewares.post?.length ?? -1) > 0)
30 app.use(config.middlewares.post);
31
32 app.listen(3003, () => {
33 context.utils.logger.info(
34 `${kleur.green().bold("🚀 Your application is ready!")}
35 > ${kleur.bold("Local")} : http://localhost:3003`
36 );
37 vite.watcher.add(viteNormalizePath(context.utils.pageDir));
38 vite.watcher.add(viteNormalizePath(context.utils.i18nDir));
39 polyfill(global, {
40 exclude: "window document",
41 });
42 });
43
44 return vite;
45}

Callers 1

devActionFunction · 0.90

Calls 2

createDevContextFunction · 0.90
createMiddlewaresFunction · 0.90

Tested by

no test coverage detected