vike-lite 1.13.2 → 1.13.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/vite.d.mts +2 -2
- package/dist/vite.mjs +16 -13
- package/package.json +2 -2
package/dist/vite.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Plugin } from "vite";
|
|
2
2
|
//#region src/vite/index.d.ts
|
|
3
|
-
declare function
|
|
3
|
+
declare function vikeLite({ pagesDir, serverEntry, apiPrefix, prerender }?: {
|
|
4
4
|
/**
|
|
5
5
|
* The directory where your page components are located.
|
|
6
6
|
* This is where the plugin will look for your page files to generate routes.
|
|
@@ -27,4 +27,4 @@ declare function routerPlugin({ pagesDir, serverEntry, apiPrefix, prerender }?:
|
|
|
27
27
|
prerender?: boolean;
|
|
28
28
|
}): Plugin;
|
|
29
29
|
//#endregion
|
|
30
|
-
export {
|
|
30
|
+
export { vikeLite as default };
|
package/dist/vite.mjs
CHANGED
|
@@ -99,7 +99,7 @@ async function injectFOUCStyles(server, html) {
|
|
|
99
99
|
const SUPPORTED_RENDERERS = ["solid"];
|
|
100
100
|
//#endregion
|
|
101
101
|
//#region src/vite/index.ts
|
|
102
|
-
function
|
|
102
|
+
function vikeLite({ pagesDir = "pages", serverEntry = "server/index", apiPrefix = "/api", prerender = false } = {}) {
|
|
103
103
|
const isProd = process.env.NODE_ENV === "production";
|
|
104
104
|
let viteConfigRoot;
|
|
105
105
|
let outDir;
|
|
@@ -109,8 +109,8 @@ function routerPlugin({ pagesDir = "pages", serverEntry = "server/index", apiPre
|
|
|
109
109
|
manifest: "virtual:client-manifest",
|
|
110
110
|
client: "virtual:vike-lite/client",
|
|
111
111
|
server: "virtual:vike-lite/server",
|
|
112
|
-
entryClient: "virtual:entry-client",
|
|
113
112
|
setup: "virtual:vike-lite/setup",
|
|
113
|
+
entryClient: "virtual:entry-client",
|
|
114
114
|
entryServer: "virtual:entry-server",
|
|
115
115
|
entryPrerender: "virtual:entry-prerender"
|
|
116
116
|
};
|
|
@@ -217,7 +217,7 @@ function routerPlugin({ pagesDir = "pages", serverEntry = "server/index", apiPre
|
|
|
217
217
|
if (id === RESOLVED.routes) {
|
|
218
218
|
const { routes, errorRoute } = generateRoutes(viteConfigRoot, pagesDir);
|
|
219
219
|
const isSSR = options.ssr;
|
|
220
|
-
let code = `import
|
|
220
|
+
let code = `import{onRenderHtml}from'${VIRTUAL.server}';export const config={onRenderHtml};export const routes=[`;
|
|
221
221
|
for (const r of routes) {
|
|
222
222
|
code += `{path:'${r.path}',page:'${r.page}',Page:()=>import('/${r.page}'),`;
|
|
223
223
|
if (r.head) code += `head:'${r.head}',Head:()=>import('/${r.head}'),`;
|
|
@@ -232,23 +232,26 @@ function routerPlugin({ pagesDir = "pages", serverEntry = "server/index", apiPre
|
|
|
232
232
|
}
|
|
233
233
|
code += "},";
|
|
234
234
|
}
|
|
235
|
-
code += "]
|
|
235
|
+
code += "];";
|
|
236
236
|
if (errorRoute) {
|
|
237
237
|
const e = errorRoute;
|
|
238
238
|
code += `export const errorRoute={path:'${e.path}',page:'${e.page}',Page:()=>import('/${e.page}'),`;
|
|
239
239
|
if (e.layout) code += `layout:'${e.layout}',Layout:()=>import('/${e.layout}'),`;
|
|
240
240
|
if (e.head) code += `head:'${e.head}',Head:()=>import('/${e.head}'),`;
|
|
241
|
-
code += "}
|
|
242
|
-
} else code += "export const errorRoute=null
|
|
241
|
+
code += "};";
|
|
242
|
+
} else code += "export const errorRoute=null;";
|
|
243
243
|
return code;
|
|
244
244
|
}
|
|
245
245
|
if (id === RESOLVED.manifest) {
|
|
246
|
-
if (!isProd || !options?.ssr) return "export default
|
|
246
|
+
if (!isProd || !options?.ssr) return "export default{}";
|
|
247
247
|
const manifestPath = path.join(viteConfigRoot, outDir, "client/.vite/manifest.json");
|
|
248
248
|
return `export default ${fs.readFileSync(manifestPath, "utf8")}`;
|
|
249
249
|
}
|
|
250
|
-
if (id === RESOLVED.entryClient) return `import{routes,errorRoute}from'${VIRTUAL.routes}';import{onRenderClient}from'${VIRTUAL.client}';await
|
|
251
|
-
if (id === RESOLVED.setup)
|
|
250
|
+
if (id === RESOLVED.entryClient) return `import{routes,errorRoute}from'${VIRTUAL.routes}';import{onRenderClient}from'${VIRTUAL.client}';await(await onRenderClient()).default({routes,errorRoute});`;
|
|
251
|
+
if (id === RESOLVED.setup) {
|
|
252
|
+
const manifestContent = isProd ? `(await import('${VIRTUAL.manifest}')).default` : "null";
|
|
253
|
+
return `import{routes,errorRoute,config}from'${VIRTUAL.routes}';import{setVikeState}from'vike-lite/__internal/server';const manifest=${manifestContent};setVikeState({routes,errorRoute,config,manifest});`;
|
|
254
|
+
}
|
|
252
255
|
if (id === RESOLVED.entryServer) {
|
|
253
256
|
if (serverEntry) {
|
|
254
257
|
const basePath = path.resolve(viteConfigRoot, serverEntry);
|
|
@@ -264,8 +267,8 @@ function routerPlugin({ pagesDir = "pages", serverEntry = "server/index", apiPre
|
|
|
264
267
|
if (!serverEntryPath) throw new Error(`[vike-lite] serverEntry ${serverEntry} file not found`);
|
|
265
268
|
return `import '${VIRTUAL.setup}';export * from'${serverEntryPath}';export{default}from'${serverEntryPath}';`;
|
|
266
269
|
}
|
|
267
|
-
const
|
|
268
|
-
return `import
|
|
270
|
+
const defaultServerEntryContent = isProd ? fs.readFileSync(path.resolve(viteConfigRoot, "defaultServerEntry.mjs"), "utf8") : `import{renderPage}from'vike-lite/server'\n`;
|
|
271
|
+
return `import'${VIRTUAL.setup}'\n` + defaultServerEntryContent + "export default{fetch:renderPage}\n";
|
|
269
272
|
}
|
|
270
273
|
if (id === RESOLVED.entryPrerender) return `import'${VIRTUAL.setup}';export{routes}from'${VIRTUAL.routes}';`;
|
|
271
274
|
},
|
|
@@ -320,7 +323,7 @@ function routerPlugin({ pagesDir = "pages", serverEntry = "server/index", apiPre
|
|
|
320
323
|
fs.mkdirSync(path.dirname(jsonOutPath), { recursive: true });
|
|
321
324
|
fs.writeFileSync(jsonOutPath, await jsonRes.text());
|
|
322
325
|
} else throw new Error(`[vike-lite] ❌ SSG JSON Error for "${jsonTarget}"`);
|
|
323
|
-
console.log(`
|
|
326
|
+
console.log(` → ${urlPath}`);
|
|
324
327
|
generatedCount++;
|
|
325
328
|
}
|
|
326
329
|
console.log(`[vike-lite] ✨ SSG Completed! Generated ${generatedCount} static routes`);
|
|
@@ -387,4 +390,4 @@ function routerPlugin({ pagesDir = "pages", serverEntry = "server/index", apiPre
|
|
|
387
390
|
};
|
|
388
391
|
}
|
|
389
392
|
//#endregion
|
|
390
|
-
export {
|
|
393
|
+
export { vikeLite as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vike-lite",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/node": "^26.1.1",
|
|
54
|
-
"tsdown": "^0.22.
|
|
54
|
+
"tsdown": "^0.22.7",
|
|
55
55
|
"vite": "^8.1.4"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|