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

Function createDevContext

packages/vite/src/node/context.ts:17–62  ·  view source on GitHub ↗
(
  config: TinyPagesConfig,
  createDevPlugins,
  source?: string
)

Source from the content-addressed store, hash-verified

15let buildContext: BuildContext;
16
17export async function createDevContext(
18 config: TinyPagesConfig,
19 createDevPlugins,
20 source?: string
21): Promise<[DevContext, ViteDevServer]> {
22 const { islands_cache, markdown_cache } = await createCaches(
23 config.vite.root,
24 false
25 );
26 giveComponentCache(islands_cache);
27 devContext = {
28 config,
29 page: presetPageConfig,
30 utils: {
31 logger: createLogger(config.vite.logLevel, { prefix: "[tinypages]" }),
32 async render(html: string) {
33 return await render(html, vite, devContext);
34 },
35 invalidate: (input: string) => purgeComponentCache(input),
36 pageDir: path.join(config.vite.root, "pages"),
37 stylesDir: path.join(config.vite.root, "styles"),
38 i18nDir: path.join(config.vite.root, "locales"),
39 currI18n: "",
40 configFile: source || "",
41 markdown_cache,
42 kit: pluginKit(config.modules),
43 },
44 };
45
46 /**
47 * Hook: defineConfig (dev)
48 */
49 await devContext.utils.kit.defineConfig(config);
50
51 const plugins = await createDevPlugins();
52 if (devContext.config.vite.plugins) {
53 devContext.config.vite.plugins.push(plugins);
54 vite = await createServer({ ...devContext.config.vite });
55 } else {
56 vite = await createServer({
57 ...devContext.config.vite,
58 plugins,
59 });
60 }
61 return [devContext, vite];
62}
63
64export async function createBuildContext(
65 config: TinyPagesConfig,

Callers 1

createDevServerFunction · 0.90

Calls 5

createCachesFunction · 0.90
giveComponentCacheFunction · 0.90
purgeComponentCacheFunction · 0.90
pluginKitFunction · 0.90
createDevPluginsFunction · 0.85

Tested by

no test coverage detected