MCPcopy Index your code
hub / github.com/QwikDev/qwik / buildApp

Function buildApp

starters/dev-server.ts:117–261  ·  view source on GitHub ↗
(
  appDir: string,
  appName: string,
  enableCityServer: boolean,
)

Source from the content-addressed store, hash-verified

115}
116
117async function buildApp(
118 appDir: string,
119 appName: string,
120 enableCityServer: boolean,
121) {
122 const optimizer = await import("@builder.io/qwik/optimizer");
123 const appSrcDir = join(appDir, "src");
124 const appDistDir = join(appDir, "dist");
125 const appServerDir = join(appDir, "server");
126 const basePath = `/${appName}/`;
127 const isProd = appName.includes(".prod");
128
129 // always clean the build directory
130 removeDir(appDistDir);
131 removeDir(appServerDir);
132
133 let clientManifest: QwikManifest | undefined = undefined;
134 const plugins: PluginOption[] = [];
135 if (enableCityServer) {
136 // ssr entry existed in service folder, use dev plugin to
137 // 1. export router
138 // 2. set basePath
139 plugins.push({
140 name: "devPlugin",
141 resolveId(id) {
142 if (id.endsWith(qwikCityVirtualEntry)) {
143 return qwikCityVirtualEntry;
144 }
145 if (id === qwikCityStaticPaths || id === qwikCityNotFoundPaths) {
146 return "./" + id;
147 }
148 },
149 load(id) {
150 if (id.endsWith(qwikCityVirtualEntry)) {
151 return `import { createQwikCity } from '@builder.io/qwik-city/middleware/node';
152import qwikCityPlan from '@qwik-city-plan';
153import render from '${escapeChars(resolve(appSrcDir, "entry.ssr"))}';
154const { router, notFound } = createQwikCity({
155 render,
156 qwikCityPlan,
157 base: '${basePath}build/',
158});
159export {
160 router,
161 notFound
162}
163`;
164 }
165 if (id.endsWith(qwikCityStaticPaths)) {
166 return `export function isStaticPath(method, url){ return false; };`;
167 }
168 if (id.endsWith(qwikCityNotFoundPaths)) {
169 const notFoundHtml = getErrorHtml(404, "Resource Not Found");
170 return `export function getNotFound(){ return ${JSON.stringify(
171 notFoundHtml,
172 )}; };`;
173 }
174 },

Callers 1

handleAppFunction · 0.85

Calls 5

joinFunction · 0.85
removeDirFunction · 0.85
getInlineConfFunction · 0.85
buildFunction · 0.50
resolveFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…