@analogjs/vite-plugin-nitro 3.0.0-alpha.2 → 3.0.0-alpha.20
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/package.json +14 -9
- package/src/index.d.ts +9 -9
- package/src/index.js +6 -2
- package/src/index.js.map +1 -1
- package/src/lib/build-server.d.ts +3 -2
- package/src/lib/build-server.js +100 -122
- package/src/lib/build-server.js.map +1 -1
- package/src/lib/build-sitemap.d.ts +9 -9
- package/src/lib/build-sitemap.js +130 -63
- package/src/lib/build-sitemap.js.map +1 -1
- package/src/lib/build-ssr.d.ts +3 -2
- package/src/lib/build-ssr.js +26 -18
- package/src/lib/build-ssr.js.map +1 -1
- package/src/lib/hooks/post-rendering-hook.d.ts +1 -1
- package/src/lib/hooks/post-rendering-hook.js +10 -6
- package/src/lib/hooks/post-rendering-hook.js.map +1 -1
- package/src/lib/options.d.ts +132 -106
- package/src/lib/plugins/dev-server-plugin.d.ts +3 -3
- package/src/lib/plugins/dev-server-plugin.js +91 -101
- package/src/lib/plugins/dev-server-plugin.js.map +1 -1
- package/src/lib/plugins/page-endpoints.d.ts +5 -5
- package/src/lib/plugins/page-endpoints.js +27 -62
- package/src/lib/plugins/page-endpoints.js.map +1 -1
- package/src/lib/utils/get-content-files.d.ts +54 -54
- package/src/lib/utils/get-content-files.js +88 -97
- package/src/lib/utils/get-content-files.js.map +1 -1
- package/src/lib/utils/get-page-handlers.d.ts +58 -58
- package/src/lib/utils/get-page-handlers.js +70 -84
- package/src/lib/utils/get-page-handlers.js.map +1 -1
- package/src/lib/utils/load-esm.d.ts +18 -18
- package/src/lib/utils/node-web-bridge.d.ts +1 -1
- package/src/lib/utils/node-web-bridge.js +50 -45
- package/src/lib/utils/node-web-bridge.js.map +1 -1
- package/src/lib/utils/register-dev-middleware.d.ts +12 -12
- package/src/lib/utils/register-dev-middleware.js +41 -44
- package/src/lib/utils/register-dev-middleware.js.map +1 -1
- package/src/lib/utils/renderers.d.ts +49 -38
- package/src/lib/utils/renderers.js +66 -53
- package/src/lib/utils/renderers.js.map +1 -1
- package/src/lib/utils/rolldown.d.ts +2 -0
- package/src/lib/utils/rolldown.js +12 -0
- package/src/lib/utils/rolldown.js.map +1 -0
- package/src/lib/vite-plugin-nitro.d.ts +3 -3
- package/src/lib/vite-plugin-nitro.js +741 -687
- package/src/lib/vite-plugin-nitro.js.map +1 -1
- package/README.md +0 -125
- package/src/lib/options.js +0 -2
- package/src/lib/options.js.map +0 -1
- package/src/lib/utils/load-esm.js +0 -23
- package/src/lib/utils/load-esm.js.map +0 -1
|
@@ -1,713 +1,767 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
let rendererIndexEntry = '';
|
|
1
|
+
import { buildServer, isVercelPreset } from "./build-server.js";
|
|
2
|
+
import { getBundleOptionsKey, isRolldown } from "./utils/rolldown.js";
|
|
3
|
+
import { buildClientApp, buildSSRApp } from "./build-ssr.js";
|
|
4
|
+
import { apiMiddleware, clientRenderer, ssrRenderer } from "./utils/renderers.js";
|
|
5
|
+
import { pageEndpointsPlugin } from "./plugins/page-endpoints.js";
|
|
6
|
+
import { getPageHandlers } from "./utils/get-page-handlers.js";
|
|
7
|
+
import { buildSitemap } from "./build-sitemap.js";
|
|
8
|
+
import { toWebRequest, writeWebResponseToNode } from "./utils/node-web-bridge.js";
|
|
9
|
+
import { devServerPlugin } from "./plugins/dev-server-plugin.js";
|
|
10
|
+
import { getMatchingContentFilesWithFrontMatter } from "./utils/get-content-files.js";
|
|
11
|
+
import { build, createDevServer, createNitro } from "nitro/builder";
|
|
12
|
+
import { mergeConfig, normalizePath } from "vite";
|
|
13
|
+
import { relative, resolve } from "node:path";
|
|
14
|
+
import { pathToFileURL } from "node:url";
|
|
15
|
+
import { existsSync, readFileSync, readdirSync } from "node:fs";
|
|
16
|
+
//#region packages/vite-plugin-nitro/src/lib/vite-plugin-nitro.ts
|
|
18
17
|
function createNitroMiddlewareHandler(handler) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
return {
|
|
19
|
+
route: "/**",
|
|
20
|
+
handler,
|
|
21
|
+
middleware: true
|
|
22
|
+
};
|
|
24
23
|
}
|
|
25
24
|
/**
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
25
|
+
* Creates a `rollup:before` hook that marks specified packages as external
|
|
26
|
+
* in Nitro's bundler config (applied to both the server build and the
|
|
27
|
+
* prerender build).
|
|
28
|
+
*
|
|
29
|
+
* ## Subpath matching (Rolldown compatibility)
|
|
30
|
+
*
|
|
31
|
+
* When `bundlerConfig.external` is an **array**, Rollup automatically
|
|
32
|
+
* prefix-matches entries — `'rxjs'` in the array will also externalise
|
|
33
|
+
* `'rxjs/operators'`, `'rxjs/internal/Observable'`, etc.
|
|
34
|
+
*
|
|
35
|
+
* Rolldown (the default bundler in Nitro v3) does **not** do this. It
|
|
36
|
+
* treats array entries as exact strings. To keep behaviour consistent
|
|
37
|
+
* across both bundlers, the **function** branch already needed explicit
|
|
38
|
+
* subpath matching. We now use the same `isExternal` helper for all
|
|
39
|
+
* branches so that `'rxjs'` reliably matches `'rxjs/operators'`
|
|
40
|
+
* regardless of whether the existing `external` value is a function,
|
|
41
|
+
* array, or absent.
|
|
42
|
+
*
|
|
43
|
+
* Without this, the Nitro prerender build fails on Windows CI with:
|
|
44
|
+
*
|
|
45
|
+
* [RESOLVE_ERROR] Could not resolve 'rxjs/operators'
|
|
46
|
+
*/
|
|
48
47
|
function createRollupBeforeHook(externalEntries) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
else if (typeof existing === 'function') {
|
|
60
|
-
bundlerConfig.external = (source, importer, isResolved) => existing(source, importer, isResolved) || isExternal(source);
|
|
61
|
-
}
|
|
62
|
-
else if (Array.isArray(existing)) {
|
|
63
|
-
bundlerConfig.external = [...existing, ...externalEntries];
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
bundlerConfig.external = [existing, ...externalEntries];
|
|
67
|
-
}
|
|
68
|
-
};
|
|
48
|
+
const isExternal = (source) => externalEntries.some((entry) => source === entry || source.startsWith(entry + "/"));
|
|
49
|
+
return (_nitro, bundlerConfig) => {
|
|
50
|
+
sanitizeNitroBundlerConfig(_nitro, bundlerConfig);
|
|
51
|
+
if (externalEntries.length === 0) return;
|
|
52
|
+
const existing = bundlerConfig.external;
|
|
53
|
+
if (!existing) bundlerConfig.external = externalEntries;
|
|
54
|
+
else if (typeof existing === "function") bundlerConfig.external = (source, importer, isResolved) => existing(source, importer, isResolved) || isExternal(source);
|
|
55
|
+
else if (Array.isArray(existing)) bundlerConfig.external = [...existing, ...externalEntries];
|
|
56
|
+
else bundlerConfig.external = [existing, ...externalEntries];
|
|
57
|
+
};
|
|
69
58
|
}
|
|
70
59
|
function appendNoExternals(noExternals, ...entries) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
return Array.isArray(noExternals)
|
|
75
|
-
? [...noExternals, ...entries]
|
|
76
|
-
: noExternals;
|
|
60
|
+
if (!noExternals) return entries;
|
|
61
|
+
return Array.isArray(noExternals) ? [...noExternals, ...entries] : noExternals;
|
|
77
62
|
}
|
|
78
63
|
/**
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
64
|
+
* Patches Nitro's internal Rollup/Rolldown bundler config to work around
|
|
65
|
+
* incompatibilities in the Nitro v3 alpha series.
|
|
66
|
+
*
|
|
67
|
+
* Called from the `rollup:before` hook, this function runs against the *final*
|
|
68
|
+
* bundler config that Nitro assembles for its server/prerender builds — it
|
|
69
|
+
* does NOT touch the normal Vite client or SSR environment configs.
|
|
70
|
+
*
|
|
71
|
+
* Each workaround is narrowly scoped and safe to remove once the corresponding
|
|
72
|
+
* upstream Nitro issue is resolved.
|
|
73
|
+
*/
|
|
89
74
|
function sanitizeNitroBundlerConfig(_nitro, bundlerConfig) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if ('codeSplitting' in output) {
|
|
105
|
-
delete output['codeSplitting'];
|
|
106
|
-
}
|
|
107
|
-
// ── 2. Remove invalid `output.manualChunks` ─────────────────────────
|
|
108
|
-
//
|
|
109
|
-
// Nitro's default config enables manual chunking for node_modules. Under
|
|
110
|
-
// Nitro v3 alpha + Rollup 4.59 this crashes during the prerender rebundle:
|
|
111
|
-
//
|
|
112
|
-
// Cannot read properties of undefined (reading 'included')
|
|
113
|
-
//
|
|
114
|
-
// A single server bundle is acceptable for Analog's use case, so we strip
|
|
115
|
-
// `manualChunks` until the upstream bug is fixed.
|
|
116
|
-
if ('manualChunks' in output) {
|
|
117
|
-
delete output['manualChunks'];
|
|
118
|
-
}
|
|
119
|
-
// ── 3. Escape route params in `output.chunkFileNames` ───────────────
|
|
120
|
-
//
|
|
121
|
-
// Nitro's `getChunkName()` derives chunk filenames from route patterns,
|
|
122
|
-
// using its internal `routeToFsPath()` helper to convert route params
|
|
123
|
-
// (`:productId` → `[productId]`) and catch-alls (`**` → `[...]`).
|
|
124
|
-
//
|
|
125
|
-
// Rollup/Rolldown interprets *any* `[token]` in the string returned by a
|
|
126
|
-
// `chunkFileNames` function as a placeholder. Only a handful are valid —
|
|
127
|
-
// `[name]`, `[hash]`, `[format]`, `[ext]` — so route-derived tokens like
|
|
128
|
-
// `[productId]` or `[...]` trigger a build error:
|
|
129
|
-
//
|
|
130
|
-
// "[productId]" is not a valid placeholder in the "output.chunkFileNames" pattern.
|
|
131
|
-
//
|
|
132
|
-
// We wrap the original function to replace non-standard `[token]` patterns
|
|
133
|
-
// with `_token_`, preserving the intended filename while avoiding the
|
|
134
|
-
// placeholder validation error.
|
|
135
|
-
//
|
|
136
|
-
// Example: `_routes/products/[productId].mjs` → `_routes/products/_productId_.mjs`
|
|
137
|
-
const VALID_ROLLUP_PLACEHOLDER = /^\[(?:name|hash|format|ext)\]$/;
|
|
138
|
-
const chunkFileNames = output['chunkFileNames'];
|
|
139
|
-
if (typeof chunkFileNames === 'function') {
|
|
140
|
-
const originalFn = chunkFileNames;
|
|
141
|
-
output['chunkFileNames'] = (...args) => {
|
|
142
|
-
const result = originalFn(...args);
|
|
143
|
-
if (typeof result !== 'string')
|
|
144
|
-
return result;
|
|
145
|
-
return result.replace(/\[[^\]]+\]/g, (match) => VALID_ROLLUP_PLACEHOLDER.test(match)
|
|
146
|
-
? match
|
|
147
|
-
: `_${match.slice(1, -1)}_`);
|
|
148
|
-
};
|
|
149
|
-
}
|
|
75
|
+
const output = bundlerConfig["output"];
|
|
76
|
+
if (!output || Array.isArray(output) || typeof output !== "object") return;
|
|
77
|
+
if ("codeSplitting" in output) delete output["codeSplitting"];
|
|
78
|
+
if ("manualChunks" in output) delete output["manualChunks"];
|
|
79
|
+
const VALID_ROLLUP_PLACEHOLDER = /^\[(?:name|hash|format|ext)\]$/;
|
|
80
|
+
const chunkFileNames = output["chunkFileNames"];
|
|
81
|
+
if (typeof chunkFileNames === "function") {
|
|
82
|
+
const originalFn = chunkFileNames;
|
|
83
|
+
output["chunkFileNames"] = (...args) => {
|
|
84
|
+
const result = originalFn(...args);
|
|
85
|
+
if (typeof result !== "string") return result;
|
|
86
|
+
return result.replace(/\[[^\]]+\]/g, (match) => VALID_ROLLUP_PLACEHOLDER.test(match) ? match : `_${match.slice(1, -1)}_`);
|
|
87
|
+
};
|
|
88
|
+
}
|
|
150
89
|
}
|
|
151
|
-
function resolveClientOutputPath(workspaceRoot, rootDir, configuredOutDir
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
90
|
+
function resolveClientOutputPath(cachedPath, workspaceRoot, rootDir, configuredOutDir) {
|
|
91
|
+
if (cachedPath) {
|
|
92
|
+
debugLog("resolveClientOutputPath using cached path", () => ({
|
|
93
|
+
cachedPath,
|
|
94
|
+
workspaceRoot,
|
|
95
|
+
rootDir,
|
|
96
|
+
configuredOutDir
|
|
97
|
+
}));
|
|
98
|
+
return cachedPath;
|
|
99
|
+
}
|
|
100
|
+
if (configuredOutDir) {
|
|
101
|
+
const resolvedPath = normalizePath(resolve(workspaceRoot, rootDir, configuredOutDir));
|
|
102
|
+
debugLog("resolveClientOutputPath using configured build.outDir", () => ({
|
|
103
|
+
workspaceRoot,
|
|
104
|
+
rootDir,
|
|
105
|
+
configuredOutDir,
|
|
106
|
+
resolvedPath
|
|
107
|
+
}));
|
|
108
|
+
return resolvedPath;
|
|
109
|
+
}
|
|
110
|
+
const resolvedPath = normalizePath(resolve(workspaceRoot, "dist", rootDir, "client"));
|
|
111
|
+
debugLog("resolveClientOutputPath using default dist client path", () => ({
|
|
112
|
+
workspaceRoot,
|
|
113
|
+
rootDir,
|
|
114
|
+
configuredOutDir,
|
|
115
|
+
resolvedPath
|
|
116
|
+
}));
|
|
117
|
+
return resolvedPath;
|
|
118
|
+
}
|
|
119
|
+
function getEnvironmentBuildOutDir(environment) {
|
|
120
|
+
if (!environment || typeof environment !== "object") return;
|
|
121
|
+
const environmentConfig = environment;
|
|
122
|
+
return environmentConfig.config?.build?.outDir ?? environmentConfig.build?.outDir;
|
|
123
|
+
}
|
|
124
|
+
function resolveBuiltClientOutputPath(cachedPath, workspaceRoot, rootDir, configuredOutDir, environment) {
|
|
125
|
+
const environmentOutDir = getEnvironmentBuildOutDir(environment);
|
|
126
|
+
if (environmentOutDir) {
|
|
127
|
+
const resolvedPath = normalizePath(resolve(workspaceRoot, rootDir, environmentOutDir));
|
|
128
|
+
debugLog("resolveBuiltClientOutputPath using environment outDir", () => ({
|
|
129
|
+
cachedPath,
|
|
130
|
+
workspaceRoot,
|
|
131
|
+
rootDir,
|
|
132
|
+
configuredOutDir,
|
|
133
|
+
environmentOutDir,
|
|
134
|
+
resolvedPath
|
|
135
|
+
}));
|
|
136
|
+
return resolvedPath;
|
|
137
|
+
}
|
|
138
|
+
debugLog("resolveBuiltClientOutputPath falling back to shared resolver", () => ({
|
|
139
|
+
cachedPath,
|
|
140
|
+
workspaceRoot,
|
|
141
|
+
rootDir,
|
|
142
|
+
configuredOutDir,
|
|
143
|
+
environmentOutDir
|
|
144
|
+
}));
|
|
145
|
+
return resolveClientOutputPath(cachedPath, workspaceRoot, rootDir, configuredOutDir);
|
|
146
|
+
}
|
|
147
|
+
function getNitroPublicOutputDir(nitroConfig) {
|
|
148
|
+
const publicDir = nitroConfig.output?.publicDir;
|
|
149
|
+
if (!publicDir) throw new Error("Nitro public output directory is required to build the sitemap.");
|
|
150
|
+
return publicDir;
|
|
151
|
+
}
|
|
152
|
+
var DEBUG_NAMESPACE = "analog:vite-plugin-nitro";
|
|
153
|
+
function escapeRegExp(value) {
|
|
154
|
+
return value.replace(/[|\\{}()[\]^$+?.*]/g, "\\$&");
|
|
155
|
+
}
|
|
156
|
+
function isDebugEnabled(namespace) {
|
|
157
|
+
const debugValue = process.env["DEBUG"];
|
|
158
|
+
if (!debugValue) return false;
|
|
159
|
+
return debugValue.split(/[\s,]+/).filter(Boolean).some((pattern) => {
|
|
160
|
+
return new RegExp(`^${escapeRegExp(pattern).replace(/\\\*/g, ".*")}$`).test(namespace);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
function debugLog(label, details) {
|
|
164
|
+
if (!isDebugEnabled(DEBUG_NAMESPACE)) return;
|
|
165
|
+
const resolvedDetails = typeof details === "function" ? details() : details;
|
|
166
|
+
if (resolvedDetails && Object.keys(resolvedDetails).length > 0) {
|
|
167
|
+
console.log(`DEBUG: ${label}`, resolvedDetails);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
console.log(`DEBUG: ${label}`);
|
|
171
|
+
}
|
|
172
|
+
function readDirectoryEntries(path) {
|
|
173
|
+
try {
|
|
174
|
+
return readdirSync(path).sort();
|
|
175
|
+
} catch (error) {
|
|
176
|
+
return [`<<unable to read directory: ${error instanceof Error ? error.message : String(error)}>>`];
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
function getPathDebugInfo(path) {
|
|
180
|
+
return {
|
|
181
|
+
rawPath: path,
|
|
182
|
+
normalizedPath: normalizePath(path),
|
|
183
|
+
exists: existsSync(path),
|
|
184
|
+
entries: existsSync(path) ? readDirectoryEntries(path) : []
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
function assetSourceToString(source) {
|
|
188
|
+
return typeof source === "string" ? source : Buffer.from(source).toString("utf8");
|
|
189
|
+
}
|
|
190
|
+
function captureClientIndexHtmlFromBundle(bundle, hook) {
|
|
191
|
+
const indexHtmlAsset = Object.values(bundle).find((chunk) => chunk.type === "asset" && chunk.fileName === "index.html" && typeof chunk.source !== "undefined");
|
|
192
|
+
if (!indexHtmlAsset?.source) {
|
|
193
|
+
debugLog(`client bundle did not expose index.html during ${hook}`, () => ({
|
|
194
|
+
hook,
|
|
195
|
+
bundleKeys: Object.keys(bundle).sort(),
|
|
196
|
+
assetFileNames: Object.values(bundle).filter((chunk) => chunk.type === "asset").map((chunk) => chunk.fileName).filter(Boolean)
|
|
197
|
+
}));
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
const indexHtml = assetSourceToString(indexHtmlAsset.source);
|
|
201
|
+
debugLog(`captured client bundle index.html asset during ${hook}`, () => ({
|
|
202
|
+
hook,
|
|
203
|
+
fileName: indexHtmlAsset.fileName,
|
|
204
|
+
htmlLength: indexHtml.length
|
|
205
|
+
}));
|
|
206
|
+
return indexHtml;
|
|
207
|
+
}
|
|
208
|
+
function registerIndexHtmlVirtual(nitroConfig, clientOutputPath, inlineIndexHtml) {
|
|
209
|
+
const indexHtmlPath = resolve(clientOutputPath, "index.html");
|
|
210
|
+
debugLog("registerIndexHtmlVirtual inspecting client output", () => ({
|
|
211
|
+
platform: process.platform,
|
|
212
|
+
cwd: process.cwd(),
|
|
213
|
+
clientOutputPath,
|
|
214
|
+
clientOutputPathInfo: getPathDebugInfo(clientOutputPath),
|
|
215
|
+
indexHtmlPath,
|
|
216
|
+
indexHtmlExists: existsSync(indexHtmlPath),
|
|
217
|
+
hasInlineIndexHtml: typeof inlineIndexHtml === "string"
|
|
218
|
+
}));
|
|
219
|
+
if (!existsSync(indexHtmlPath) && typeof inlineIndexHtml !== "string") {
|
|
220
|
+
debugLog("registerIndexHtmlVirtual missing index.html", () => ({
|
|
221
|
+
platform: process.platform,
|
|
222
|
+
cwd: process.cwd(),
|
|
223
|
+
clientOutputPath,
|
|
224
|
+
clientOutputPathInfo: getPathDebugInfo(clientOutputPath),
|
|
225
|
+
indexHtmlPath,
|
|
226
|
+
hasInlineIndexHtml: typeof inlineIndexHtml === "string",
|
|
227
|
+
nitroOutput: nitroConfig.output,
|
|
228
|
+
nitroPublicAssets: nitroConfig.publicAssets
|
|
229
|
+
}));
|
|
230
|
+
throw new Error(`[analog] Client build output not found at ${indexHtmlPath}.\nEnsure the client environment build completed successfully before the server build.`);
|
|
231
|
+
}
|
|
232
|
+
const indexHtml = typeof inlineIndexHtml === "string" ? inlineIndexHtml : readFileSync(indexHtmlPath, "utf8");
|
|
233
|
+
debugLog("registerIndexHtmlVirtual using HTML template source", () => ({
|
|
234
|
+
source: typeof inlineIndexHtml === "string" ? "captured client bundle asset" : "client output index.html file",
|
|
235
|
+
indexHtmlPath
|
|
236
|
+
}));
|
|
237
|
+
nitroConfig.virtual = {
|
|
238
|
+
...nitroConfig.virtual,
|
|
239
|
+
"#analog/index": `export default ${JSON.stringify(indexHtml)};`
|
|
240
|
+
};
|
|
161
241
|
}
|
|
162
242
|
/**
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
243
|
+
* Converts the built SSR entry path into a specifier that Nitro's bundler
|
|
244
|
+
* can resolve, including all relative `./assets/*` chunk imports inside
|
|
245
|
+
* the entry.
|
|
246
|
+
*
|
|
247
|
+
* The returned path **must** be an absolute filesystem path with forward
|
|
248
|
+
* slashes (e.g. `D:/a/analog/dist/apps/blog-app/ssr/main.server.js`).
|
|
249
|
+
* This lets Rollup/Rolldown determine the entry's directory and resolve
|
|
250
|
+
* sibling chunk imports like `./assets/core-DTazUigR.js` correctly.
|
|
251
|
+
*
|
|
252
|
+
* ## Why not pathToFileURL() on Windows?
|
|
253
|
+
*
|
|
254
|
+
* Earlier versions converted the path to a `file:///D:/a/...` URL on
|
|
255
|
+
* Windows, which worked with Nitro v2 + Rollup. Nitro v3 switched its
|
|
256
|
+
* default bundler to Rolldown, and Rolldown does **not** extract the
|
|
257
|
+
* importer directory from `file://` URLs. This caused every relative
|
|
258
|
+
* import inside the SSR entry to fail during the prerender build:
|
|
259
|
+
*
|
|
260
|
+
* [RESOLVE_ERROR] Could not resolve './assets/core-DTazUigR.js'
|
|
261
|
+
* in ../../dist/apps/blog-app/ssr/main.server.js
|
|
262
|
+
*
|
|
263
|
+
* `normalizePath()` (from Vite) simply converts backslashes to forward
|
|
264
|
+
* slashes, which both Rollup and Rolldown handle correctly on all
|
|
265
|
+
* platforms.
|
|
266
|
+
*/
|
|
187
267
|
function toNitroSsrEntrypointSpecifier(ssrEntryPath) {
|
|
188
|
-
|
|
268
|
+
return normalizePath(ssrEntryPath);
|
|
269
|
+
}
|
|
270
|
+
function applySsrEntryAlias(nitroConfig, options, workspaceRoot, rootDir) {
|
|
271
|
+
const ssrOutDir = options?.ssrBuildDir || resolve(workspaceRoot, "dist", rootDir, "ssr");
|
|
272
|
+
if (options?.ssr || nitroConfig.prerender?.routes?.length) {
|
|
273
|
+
const ssrEntry = toNitroSsrEntrypointSpecifier(resolveBuiltSsrEntryPath(ssrOutDir));
|
|
274
|
+
nitroConfig.alias = {
|
|
275
|
+
...nitroConfig.alias,
|
|
276
|
+
"#analog/ssr": ssrEntry
|
|
277
|
+
};
|
|
278
|
+
}
|
|
189
279
|
}
|
|
190
280
|
function resolveBuiltSsrEntryPath(ssrOutDir) {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
}
|
|
200
|
-
return ssrEntryPath;
|
|
281
|
+
const candidatePaths = [
|
|
282
|
+
resolve(ssrOutDir, "main.server.mjs"),
|
|
283
|
+
resolve(ssrOutDir, "main.server.js"),
|
|
284
|
+
resolve(ssrOutDir, "main.server")
|
|
285
|
+
];
|
|
286
|
+
const ssrEntryPath = candidatePaths.find((candidatePath) => existsSync(candidatePath));
|
|
287
|
+
if (!ssrEntryPath) throw new Error(`Unable to locate the built SSR entry in "${ssrOutDir}". Expected one of: ${candidatePaths.join(", ")}`);
|
|
288
|
+
return ssrEntryPath;
|
|
201
289
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
const ssrEntryPath = resolveBuiltSsrEntryPath(closeBundleSsrOutDir);
|
|
603
|
-
const ssrEntry = toNitroSsrEntrypointSpecifier(ssrEntryPath);
|
|
604
|
-
nitroConfig.alias = {
|
|
605
|
-
...nitroConfig.alias,
|
|
606
|
-
'#analog/ssr': ssrEntry,
|
|
607
|
-
};
|
|
608
|
-
}
|
|
609
|
-
await buildServer(options, nitroConfig, routeSourceFiles);
|
|
610
|
-
console.log(`\n\nThe '@analogjs/platform' server has been successfully built.`);
|
|
611
|
-
}
|
|
612
|
-
},
|
|
613
|
-
},
|
|
614
|
-
{
|
|
615
|
-
name: '@analogjs/vite-plugin-nitro-api-prefix',
|
|
616
|
-
config() {
|
|
617
|
-
return {
|
|
618
|
-
define: {
|
|
619
|
-
ANALOG_API_PREFIX: `"${baseURL.substring(1)}${apiPrefix.substring(1)}"`,
|
|
620
|
-
},
|
|
621
|
-
};
|
|
622
|
-
},
|
|
623
|
-
},
|
|
624
|
-
];
|
|
290
|
+
function nitro(options, nitroOptions) {
|
|
291
|
+
const workspaceRoot = options?.workspaceRoot ?? process.cwd();
|
|
292
|
+
const sourceRoot = options?.sourceRoot ?? "src";
|
|
293
|
+
let isTest = process.env.NODE_ENV === "test" || !!process.env["VITEST"];
|
|
294
|
+
const baseURL = process.env["NITRO_APP_BASE_URL"] || "";
|
|
295
|
+
const prefix = baseURL ? baseURL.substring(0, baseURL.length - 1) : "";
|
|
296
|
+
const apiPrefix = `/${options?.apiPrefix || "api"}`;
|
|
297
|
+
const useAPIMiddleware = typeof options?.useAPIMiddleware !== "undefined" ? options?.useAPIMiddleware : true;
|
|
298
|
+
const viteRolldownOutput = options?.vite?.build?.rolldownOptions?.output;
|
|
299
|
+
const viteRolldownOutputConfig = viteRolldownOutput && !Array.isArray(viteRolldownOutput) ? viteRolldownOutput : void 0;
|
|
300
|
+
const codeSplitting = viteRolldownOutputConfig?.codeSplitting;
|
|
301
|
+
let isBuild = false;
|
|
302
|
+
let isServe = false;
|
|
303
|
+
let ssrBuild = false;
|
|
304
|
+
let config;
|
|
305
|
+
let nitroConfig;
|
|
306
|
+
let environmentBuild = false;
|
|
307
|
+
let hasAPIDir = false;
|
|
308
|
+
let clientOutputPath = "";
|
|
309
|
+
let clientIndexHtml;
|
|
310
|
+
let legacyClientSubBuild = false;
|
|
311
|
+
const rollupExternalEntries = [];
|
|
312
|
+
const sitemapRoutes = [];
|
|
313
|
+
const routeSitemaps = {};
|
|
314
|
+
const routeSourceFiles = {};
|
|
315
|
+
let rootDir = workspaceRoot;
|
|
316
|
+
return [
|
|
317
|
+
options?.ssr ? devServerPlugin({
|
|
318
|
+
entryServer: options?.entryServer,
|
|
319
|
+
index: options?.index,
|
|
320
|
+
routeRules: nitroOptions?.routeRules
|
|
321
|
+
}) : false,
|
|
322
|
+
{
|
|
323
|
+
name: "@analogjs/vite-plugin-nitro",
|
|
324
|
+
async config(userConfig, { mode, command }) {
|
|
325
|
+
isServe = command === "serve";
|
|
326
|
+
isBuild = command === "build";
|
|
327
|
+
ssrBuild = userConfig.build?.ssr === true;
|
|
328
|
+
config = userConfig;
|
|
329
|
+
isTest = isTest ? isTest : mode === "test";
|
|
330
|
+
rollupExternalEntries.length = 0;
|
|
331
|
+
clientIndexHtml = void 0;
|
|
332
|
+
sitemapRoutes.length = 0;
|
|
333
|
+
for (const key of Object.keys(routeSitemaps)) delete routeSitemaps[key];
|
|
334
|
+
for (const key of Object.keys(routeSourceFiles)) delete routeSourceFiles[key];
|
|
335
|
+
const resolvedConfigRoot = config.root ? resolve(workspaceRoot, config.root) : workspaceRoot;
|
|
336
|
+
rootDir = relative(workspaceRoot, resolvedConfigRoot) || ".";
|
|
337
|
+
hasAPIDir = existsSync(resolve(workspaceRoot, rootDir, `${sourceRoot}/server/routes/${options?.apiPrefix || "api"}`));
|
|
338
|
+
const buildPreset = process.env["BUILD_PRESET"] ?? nitroOptions?.preset ?? (process.env["VERCEL"] ? "vercel" : void 0);
|
|
339
|
+
const pageHandlers = getPageHandlers({
|
|
340
|
+
workspaceRoot,
|
|
341
|
+
sourceRoot,
|
|
342
|
+
rootDir,
|
|
343
|
+
additionalPagesDirs: options?.additionalPagesDirs,
|
|
344
|
+
hasAPIDir
|
|
345
|
+
});
|
|
346
|
+
const resolvedClientOutputPath = resolveClientOutputPath(clientOutputPath, workspaceRoot, rootDir, config.build?.outDir);
|
|
347
|
+
debugLog("nitro config resolved client output path", () => ({
|
|
348
|
+
platform: process.platform,
|
|
349
|
+
workspaceRoot,
|
|
350
|
+
configRoot: config.root,
|
|
351
|
+
resolvedConfigRoot,
|
|
352
|
+
rootDir,
|
|
353
|
+
buildOutDir: config.build?.outDir,
|
|
354
|
+
clientOutputPath,
|
|
355
|
+
resolvedClientOutputPath,
|
|
356
|
+
hasEnvironmentConfig: !!config.environments,
|
|
357
|
+
clientEnvironmentOutDir: config.environments?.["client"] && typeof config.environments["client"] === "object" && "build" in config.environments["client"] ? config.environments["client"].build?.outDir : void 0
|
|
358
|
+
}));
|
|
359
|
+
nitroConfig = {
|
|
360
|
+
rootDir: normalizePath(rootDir),
|
|
361
|
+
preset: buildPreset,
|
|
362
|
+
compatibilityDate: "2025-11-19",
|
|
363
|
+
logLevel: nitroOptions?.logLevel || 0,
|
|
364
|
+
serverDir: normalizePath(`${sourceRoot}/server`),
|
|
365
|
+
scanDirs: [normalizePath(`${rootDir}/${sourceRoot}/server`), ...(options?.additionalAPIDirs || []).map((dir) => normalizePath(`${workspaceRoot}${dir}`))],
|
|
366
|
+
output: {
|
|
367
|
+
dir: normalizePath(resolve(workspaceRoot, "dist", rootDir, "analog")),
|
|
368
|
+
publicDir: normalizePath(resolve(workspaceRoot, "dist", rootDir, "analog/public"))
|
|
369
|
+
},
|
|
370
|
+
buildDir: normalizePath(resolve(workspaceRoot, "dist", rootDir, ".nitro")),
|
|
371
|
+
typescript: { generateTsConfig: false },
|
|
372
|
+
runtimeConfig: {
|
|
373
|
+
apiPrefix: apiPrefix.substring(1),
|
|
374
|
+
prefix
|
|
375
|
+
},
|
|
376
|
+
renderer: false,
|
|
377
|
+
imports: { autoImport: false },
|
|
378
|
+
hooks: { "rollup:before": createRollupBeforeHook(rollupExternalEntries) },
|
|
379
|
+
rollupConfig: {
|
|
380
|
+
onwarn(warning) {
|
|
381
|
+
if (warning.message.includes("empty chunk") && warning.message.endsWith(".server")) return;
|
|
382
|
+
},
|
|
383
|
+
plugins: [pageEndpointsPlugin()]
|
|
384
|
+
},
|
|
385
|
+
handlers: [...hasAPIDir ? [] : useAPIMiddleware ? [createNitroMiddlewareHandler("#ANALOG_API_MIDDLEWARE")] : [], ...pageHandlers],
|
|
386
|
+
routeRules: hasAPIDir ? void 0 : useAPIMiddleware ? void 0 : { [`${prefix}${apiPrefix}/**`]: { proxy: { to: "/**" } } },
|
|
387
|
+
virtual: {
|
|
388
|
+
"#ANALOG_SSR_RENDERER": ssrRenderer(),
|
|
389
|
+
"#ANALOG_CLIENT_RENDERER": clientRenderer(),
|
|
390
|
+
...hasAPIDir ? {} : { "#ANALOG_API_MIDDLEWARE": apiMiddleware }
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
if (isVercelPreset(buildPreset)) nitroConfig = withVercelOutputAPI(nitroConfig, workspaceRoot);
|
|
394
|
+
if (isCloudflarePreset(buildPreset)) nitroConfig = withCloudflareOutput(nitroConfig);
|
|
395
|
+
if (isNetlifyPreset(buildPreset) && rootDir === "." && !existsSync(resolve(workspaceRoot, "netlify.toml"))) nitroConfig = withNetlifyOutputAPI(nitroConfig, workspaceRoot);
|
|
396
|
+
if (isFirebaseAppHosting()) nitroConfig = withAppHostingOutput(nitroConfig);
|
|
397
|
+
if (!ssrBuild && !isTest) {
|
|
398
|
+
clientOutputPath = resolvedClientOutputPath;
|
|
399
|
+
debugLog("nitro config cached client output path for later SSR/Nitro build", () => ({
|
|
400
|
+
ssrBuild,
|
|
401
|
+
isTest,
|
|
402
|
+
clientOutputPath
|
|
403
|
+
}));
|
|
404
|
+
}
|
|
405
|
+
nitroConfig.alias = {};
|
|
406
|
+
if (isBuild) {
|
|
407
|
+
nitroConfig.publicAssets = [{
|
|
408
|
+
dir: normalizePath(resolvedClientOutputPath),
|
|
409
|
+
maxAge: 0
|
|
410
|
+
}];
|
|
411
|
+
const rendererHandler = options?.ssr ? "#ANALOG_SSR_RENDERER" : "#ANALOG_CLIENT_RENDERER";
|
|
412
|
+
nitroConfig.handlers = [...nitroConfig.handlers || [], {
|
|
413
|
+
handler: rendererHandler,
|
|
414
|
+
route: "/**",
|
|
415
|
+
lazy: true
|
|
416
|
+
}];
|
|
417
|
+
if (isEmptyPrerenderRoutes(options)) {
|
|
418
|
+
nitroConfig.prerender = {};
|
|
419
|
+
nitroConfig.prerender.routes = ["/"];
|
|
420
|
+
}
|
|
421
|
+
if (options?.prerender) {
|
|
422
|
+
nitroConfig.prerender = nitroConfig.prerender ?? {};
|
|
423
|
+
nitroConfig.prerender.crawlLinks = options?.prerender?.discover;
|
|
424
|
+
let routes = [];
|
|
425
|
+
const prerenderRoutes = options?.prerender?.routes;
|
|
426
|
+
const hasExplicitPrerenderRoutes = typeof prerenderRoutes === "function" || Array.isArray(prerenderRoutes);
|
|
427
|
+
if (isArrayWithElements(prerenderRoutes)) routes = prerenderRoutes;
|
|
428
|
+
else if (typeof prerenderRoutes === "function") routes = await prerenderRoutes();
|
|
429
|
+
const resolvedPrerenderRoutes = routes.reduce((prev, current) => {
|
|
430
|
+
if (!current) return prev;
|
|
431
|
+
if (typeof current === "string") {
|
|
432
|
+
prev.push(current);
|
|
433
|
+
sitemapRoutes.push(current);
|
|
434
|
+
return prev;
|
|
435
|
+
}
|
|
436
|
+
if ("route" in current) {
|
|
437
|
+
if (current.sitemap) routeSitemaps[current.route] = current.sitemap;
|
|
438
|
+
if (current.outputSourceFile) {
|
|
439
|
+
const sourcePath = resolve(workspaceRoot, rootDir, current.outputSourceFile);
|
|
440
|
+
routeSourceFiles[current.route] = readFileSync(sourcePath, "utf8");
|
|
441
|
+
}
|
|
442
|
+
prev.push(current.route);
|
|
443
|
+
sitemapRoutes.push(current.route);
|
|
444
|
+
if ("staticData" in current) prev.push(`${apiPrefix}/_analog/pages/${current.route}`);
|
|
445
|
+
return prev;
|
|
446
|
+
}
|
|
447
|
+
getMatchingContentFilesWithFrontMatter(workspaceRoot, rootDir, current.contentDir).forEach((f) => {
|
|
448
|
+
const result = current.transform(f);
|
|
449
|
+
if (result) {
|
|
450
|
+
if (current.sitemap) routeSitemaps[result] = current.sitemap && typeof current.sitemap === "function" ? current.sitemap?.(f) : current.sitemap;
|
|
451
|
+
if (current.outputSourceFile) {
|
|
452
|
+
const sourceContent = current.outputSourceFile(f);
|
|
453
|
+
if (sourceContent) routeSourceFiles[result] = sourceContent;
|
|
454
|
+
}
|
|
455
|
+
prev.push(result);
|
|
456
|
+
sitemapRoutes.push(result);
|
|
457
|
+
if ("staticData" in current) prev.push(`${apiPrefix}/_analog/pages/${result}`);
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
return prev;
|
|
461
|
+
}, []);
|
|
462
|
+
nitroConfig.prerender.routes = hasExplicitPrerenderRoutes || resolvedPrerenderRoutes.length ? resolvedPrerenderRoutes : nitroConfig.prerender.routes ?? [];
|
|
463
|
+
}
|
|
464
|
+
if (ssrBuild || options?.ssr || nitroConfig.prerender?.routes?.length) {
|
|
465
|
+
if (process.platform === "win32") nitroConfig.noExternals = appendNoExternals(nitroConfig.noExternals, "std-env");
|
|
466
|
+
rollupExternalEntries.push("rxjs", "node-fetch-native/dist/polyfill", "sharp");
|
|
467
|
+
nitroConfig = {
|
|
468
|
+
...nitroConfig,
|
|
469
|
+
moduleSideEffects: ["zone.js/node", "zone.js/fesm2015/zone-node"],
|
|
470
|
+
handlers: [
|
|
471
|
+
...hasAPIDir ? [] : useAPIMiddleware ? [createNitroMiddlewareHandler("#ANALOG_API_MIDDLEWARE")] : [],
|
|
472
|
+
...pageHandlers,
|
|
473
|
+
{
|
|
474
|
+
handler: rendererHandler,
|
|
475
|
+
route: "/**",
|
|
476
|
+
lazy: true
|
|
477
|
+
}
|
|
478
|
+
]
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
nitroConfig = mergeConfig(nitroConfig, nitroOptions);
|
|
483
|
+
if (environmentBuild || ssrBuild || isServe) return {};
|
|
484
|
+
return {
|
|
485
|
+
environments: {
|
|
486
|
+
client: { build: {
|
|
487
|
+
outDir: config?.build?.outDir || resolve(workspaceRoot, "dist", rootDir, "client"),
|
|
488
|
+
emptyOutDir: true,
|
|
489
|
+
...isRolldown() && codeSplitting !== void 0 ? { rolldownOptions: { output: {
|
|
490
|
+
...viteRolldownOutputConfig,
|
|
491
|
+
codeSplitting
|
|
492
|
+
} } } : {}
|
|
493
|
+
} },
|
|
494
|
+
ssr: { build: {
|
|
495
|
+
ssr: true,
|
|
496
|
+
[getBundleOptionsKey()]: { input: options?.entryServer || resolve(workspaceRoot, rootDir, `${sourceRoot}/main.server.ts`) },
|
|
497
|
+
outDir: options?.ssrBuildDir || resolve(workspaceRoot, "dist", rootDir, "ssr"),
|
|
498
|
+
emptyOutDir: false
|
|
499
|
+
} }
|
|
500
|
+
},
|
|
501
|
+
builder: {
|
|
502
|
+
sharedPlugins: true,
|
|
503
|
+
buildApp: async (builder) => {
|
|
504
|
+
environmentBuild = true;
|
|
505
|
+
debugLog("builder.buildApp starting", () => ({
|
|
506
|
+
platform: process.platform,
|
|
507
|
+
workspaceRoot,
|
|
508
|
+
rootDir,
|
|
509
|
+
cachedClientOutputPath: clientOutputPath,
|
|
510
|
+
configuredBuildOutDir: config.build?.outDir,
|
|
511
|
+
clientEnvironmentOutDir: getEnvironmentBuildOutDir(builder.environments["client"]),
|
|
512
|
+
ssrEnvironmentOutDir: getEnvironmentBuildOutDir(builder.environments["ssr"])
|
|
513
|
+
}));
|
|
514
|
+
await builder.build(builder.environments["client"]);
|
|
515
|
+
const postClientBuildOutputPath = resolveBuiltClientOutputPath(clientOutputPath, workspaceRoot, rootDir, config.build?.outDir, builder.environments["client"]);
|
|
516
|
+
registerIndexHtmlVirtual(nitroConfig, postClientBuildOutputPath, clientIndexHtml);
|
|
517
|
+
debugLog("builder.buildApp completed client build", () => ({
|
|
518
|
+
postClientBuildOutputPath,
|
|
519
|
+
postClientBuildOutputInfo: getPathDebugInfo(postClientBuildOutputPath),
|
|
520
|
+
postClientBuildIndexHtmlPath: resolve(postClientBuildOutputPath, "index.html"),
|
|
521
|
+
postClientBuildIndexHtmlExists: existsSync(resolve(postClientBuildOutputPath, "index.html"))
|
|
522
|
+
}));
|
|
523
|
+
if (options?.ssr || nitroConfig.prerender?.routes?.length) {
|
|
524
|
+
debugLog("builder.buildApp starting SSR build", () => ({
|
|
525
|
+
ssrEnabled: options?.ssr,
|
|
526
|
+
prerenderRoutes: nitroConfig.prerender?.routes
|
|
527
|
+
}));
|
|
528
|
+
await builder.build(builder.environments["ssr"]);
|
|
529
|
+
debugLog("builder.buildApp completed SSR build", () => ({ ssrOutputPath: options?.ssrBuildDir || resolve(workspaceRoot, "dist", rootDir, "ssr") }));
|
|
530
|
+
}
|
|
531
|
+
applySsrEntryAlias(nitroConfig, options, workspaceRoot, rootDir);
|
|
532
|
+
const resolvedClientOutputPath = resolveBuiltClientOutputPath(clientOutputPath, workspaceRoot, rootDir, config.build?.outDir, builder.environments["client"]);
|
|
533
|
+
nitroConfig.publicAssets = [{
|
|
534
|
+
dir: normalizePath(resolvedClientOutputPath),
|
|
535
|
+
maxAge: 0
|
|
536
|
+
}];
|
|
537
|
+
debugLog("builder.buildApp resolved final client output path before Nitro build", () => ({
|
|
538
|
+
resolvedClientOutputPath,
|
|
539
|
+
resolvedClientOutputInfo: getPathDebugInfo(resolvedClientOutputPath),
|
|
540
|
+
nitroPublicAssets: nitroConfig.publicAssets
|
|
541
|
+
}));
|
|
542
|
+
await buildServer(options, nitroConfig, routeSourceFiles);
|
|
543
|
+
if (nitroConfig.prerender?.routes?.length && options?.prerender?.sitemap) {
|
|
544
|
+
console.log("Building Sitemap...");
|
|
545
|
+
await buildSitemap(config, options.prerender.sitemap, sitemapRoutes.length ? sitemapRoutes : nitroConfig.prerender.routes, getNitroPublicOutputDir(nitroConfig), routeSitemaps, { apiPrefix: options?.apiPrefix || "api" });
|
|
546
|
+
}
|
|
547
|
+
console.log(`\n\nThe '@analogjs/platform' server has been successfully built.`);
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
},
|
|
552
|
+
generateBundle(_options, bundle) {
|
|
553
|
+
if (!isBuild || ssrBuild) return;
|
|
554
|
+
clientIndexHtml = captureClientIndexHtmlFromBundle(bundle, "generateBundle") ?? clientIndexHtml;
|
|
555
|
+
},
|
|
556
|
+
writeBundle(_options, bundle) {
|
|
557
|
+
if (!isBuild || ssrBuild) return;
|
|
558
|
+
clientIndexHtml = captureClientIndexHtmlFromBundle(bundle, "writeBundle") ?? clientIndexHtml;
|
|
559
|
+
},
|
|
560
|
+
async configureServer(viteServer) {
|
|
561
|
+
if (isServe && !isTest) {
|
|
562
|
+
const nitro = await createNitro({
|
|
563
|
+
dev: true,
|
|
564
|
+
builder: "rollup",
|
|
565
|
+
...nitroConfig
|
|
566
|
+
});
|
|
567
|
+
const server = createDevServer(nitro);
|
|
568
|
+
await build(nitro);
|
|
569
|
+
const nitroSourceRoots = [normalizePath(resolve(workspaceRoot, rootDir, `${sourceRoot}/server`)), ...(options?.additionalAPIDirs || []).map((dir) => normalizePath(`${workspaceRoot}${dir}`))];
|
|
570
|
+
const isNitroSourceFile = (path) => {
|
|
571
|
+
const normalizedPath = normalizePath(path);
|
|
572
|
+
return nitroSourceRoots.some((root) => normalizedPath === root || normalizedPath.startsWith(`${root}/`));
|
|
573
|
+
};
|
|
574
|
+
let nitroRebuildPromise;
|
|
575
|
+
let nitroRebuildPending = false;
|
|
576
|
+
const rebuildNitroServer = () => {
|
|
577
|
+
if (nitroRebuildPromise) {
|
|
578
|
+
nitroRebuildPending = true;
|
|
579
|
+
return nitroRebuildPromise;
|
|
580
|
+
}
|
|
581
|
+
nitroRebuildPromise = (async () => {
|
|
582
|
+
do {
|
|
583
|
+
nitroRebuildPending = false;
|
|
584
|
+
await build(nitro);
|
|
585
|
+
} while (nitroRebuildPending);
|
|
586
|
+
viteServer.ws.send({ type: "full-reload" });
|
|
587
|
+
})().catch((error) => {
|
|
588
|
+
viteServer.config.logger.error(`[analog] Failed to rebuild Nitro dev server.\n${error instanceof Error ? error.stack || error.message : String(error)}`);
|
|
589
|
+
}).finally(() => {
|
|
590
|
+
nitroRebuildPromise = void 0;
|
|
591
|
+
});
|
|
592
|
+
return nitroRebuildPromise;
|
|
593
|
+
};
|
|
594
|
+
const onNitroSourceChange = (path) => {
|
|
595
|
+
if (!isNitroSourceFile(path)) return;
|
|
596
|
+
rebuildNitroServer();
|
|
597
|
+
};
|
|
598
|
+
viteServer.watcher.on("add", onNitroSourceChange);
|
|
599
|
+
viteServer.watcher.on("change", onNitroSourceChange);
|
|
600
|
+
viteServer.watcher.on("unlink", onNitroSourceChange);
|
|
601
|
+
const apiHandler = async (req, res) => {
|
|
602
|
+
await writeWebResponseToNode(res, await server.fetch(toWebRequest(req)));
|
|
603
|
+
};
|
|
604
|
+
if (hasAPIDir) viteServer.middlewares.use((req, res, next) => {
|
|
605
|
+
if (req.url?.startsWith(`${prefix}${apiPrefix}`)) {
|
|
606
|
+
apiHandler(req, res).catch((error) => next(error));
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
next();
|
|
610
|
+
});
|
|
611
|
+
else viteServer.middlewares.use(apiPrefix, (req, res, next) => {
|
|
612
|
+
apiHandler(req, res).catch((error) => next(error));
|
|
613
|
+
});
|
|
614
|
+
viteServer.httpServer?.once("listening", () => {
|
|
615
|
+
process.env["ANALOG_HOST"] = !viteServer.config.server.host ? "localhost" : viteServer.config.server.host;
|
|
616
|
+
process.env["ANALOG_PORT"] = `${viteServer.config.server.port}`;
|
|
617
|
+
});
|
|
618
|
+
if (nitroOptions?.experimental?.websocket) viteServer.httpServer?.on("upgrade", server.upgrade);
|
|
619
|
+
console.log(`\n\nThe server endpoints are accessible under the "${prefix}${apiPrefix}" path.`);
|
|
620
|
+
}
|
|
621
|
+
},
|
|
622
|
+
async closeBundle() {
|
|
623
|
+
if (legacyClientSubBuild) return;
|
|
624
|
+
if (environmentBuild) return;
|
|
625
|
+
if (ssrBuild) return;
|
|
626
|
+
if (isBuild) {
|
|
627
|
+
const resolvedClientOutputPath = resolveClientOutputPath(clientOutputPath, workspaceRoot, rootDir, config.build?.outDir);
|
|
628
|
+
debugLog("closeBundle resolved client output path before legacy SSR build", () => ({
|
|
629
|
+
platform: process.platform,
|
|
630
|
+
workspaceRoot,
|
|
631
|
+
rootDir,
|
|
632
|
+
cachedClientOutputPath: clientOutputPath,
|
|
633
|
+
configuredBuildOutDir: config.build?.outDir,
|
|
634
|
+
resolvedClientOutputPath,
|
|
635
|
+
resolvedClientOutputInfo: getPathDebugInfo(resolvedClientOutputPath)
|
|
636
|
+
}));
|
|
637
|
+
const indexHtmlPath = resolve(resolvedClientOutputPath, "index.html");
|
|
638
|
+
if (!existsSync(indexHtmlPath) && typeof clientIndexHtml !== "string") {
|
|
639
|
+
debugLog("closeBundle rebuilding missing client output before SSR/Nitro", () => ({
|
|
640
|
+
platform: process.platform,
|
|
641
|
+
workspaceRoot,
|
|
642
|
+
rootDir,
|
|
643
|
+
configuredBuildOutDir: config.build?.outDir,
|
|
644
|
+
resolvedClientOutputPath,
|
|
645
|
+
indexHtmlPath
|
|
646
|
+
}));
|
|
647
|
+
legacyClientSubBuild = true;
|
|
648
|
+
try {
|
|
649
|
+
await buildClientApp(config, options);
|
|
650
|
+
} finally {
|
|
651
|
+
legacyClientSubBuild = false;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
registerIndexHtmlVirtual(nitroConfig, resolvedClientOutputPath, clientIndexHtml);
|
|
655
|
+
if (options?.ssr) {
|
|
656
|
+
console.log("Building SSR application...");
|
|
657
|
+
await buildSSRApp(config, options);
|
|
658
|
+
debugLog("closeBundle completed standalone SSR build", () => ({
|
|
659
|
+
ssrBuildDir: options?.ssrBuildDir || resolve(workspaceRoot, "dist", rootDir, "ssr"),
|
|
660
|
+
clientOutputPathInfo: clientOutputPath ? getPathDebugInfo(clientOutputPath) : null
|
|
661
|
+
}));
|
|
662
|
+
}
|
|
663
|
+
applySsrEntryAlias(nitroConfig, options, workspaceRoot, rootDir);
|
|
664
|
+
debugLog("closeBundle resolved client output path before Nitro build", () => ({
|
|
665
|
+
platform: process.platform,
|
|
666
|
+
workspaceRoot,
|
|
667
|
+
rootDir,
|
|
668
|
+
cachedClientOutputPath: clientOutputPath,
|
|
669
|
+
configuredBuildOutDir: config.build?.outDir,
|
|
670
|
+
resolvedClientOutputPath,
|
|
671
|
+
resolvedClientOutputInfo: getPathDebugInfo(resolvedClientOutputPath)
|
|
672
|
+
}));
|
|
673
|
+
registerIndexHtmlVirtual(nitroConfig, resolvedClientOutputPath, clientIndexHtml);
|
|
674
|
+
await buildServer(options, nitroConfig, routeSourceFiles);
|
|
675
|
+
if (nitroConfig.prerender?.routes?.length && options?.prerender?.sitemap) {
|
|
676
|
+
console.log("Building Sitemap...");
|
|
677
|
+
await buildSitemap(config, options.prerender.sitemap, sitemapRoutes.length ? sitemapRoutes : nitroConfig.prerender.routes, getNitroPublicOutputDir(nitroConfig), routeSitemaps, { apiPrefix: options?.apiPrefix || "api" });
|
|
678
|
+
}
|
|
679
|
+
console.log(`\n\nThe '@analogjs/platform' server has been successfully built.`);
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
},
|
|
683
|
+
{
|
|
684
|
+
name: "@analogjs/vite-plugin-nitro-api-prefix",
|
|
685
|
+
config() {
|
|
686
|
+
return { define: { ANALOG_API_PREFIX: `"${baseURL.substring(1)}${apiPrefix.substring(1)}"` } };
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
];
|
|
625
690
|
}
|
|
626
691
|
function isEmptyPrerenderRoutes(options) {
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
}
|
|
630
|
-
return !options.prerender?.routes;
|
|
692
|
+
if (!options || isArrayWithElements(options?.prerender?.routes)) return false;
|
|
693
|
+
return !options.prerender?.routes;
|
|
631
694
|
}
|
|
632
695
|
function isArrayWithElements(arr) {
|
|
633
|
-
|
|
696
|
+
return !!(Array.isArray(arr) && arr.length);
|
|
634
697
|
}
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
output: {
|
|
652
|
-
...nitroConfig?.output,
|
|
653
|
-
dir: normalizePath(resolve(workspaceRoot, '.vercel', 'output')),
|
|
654
|
-
publicDir: normalizePath(resolve(workspaceRoot, '.vercel', 'output/static')),
|
|
655
|
-
},
|
|
698
|
+
var withVercelOutputAPI = (nitroConfig, workspaceRoot) => ({
|
|
699
|
+
...nitroConfig,
|
|
700
|
+
preset: nitroConfig?.preset ?? "vercel",
|
|
701
|
+
vercel: {
|
|
702
|
+
...nitroConfig?.vercel,
|
|
703
|
+
entryFormat: nitroConfig?.vercel?.entryFormat ?? "node",
|
|
704
|
+
functions: {
|
|
705
|
+
runtime: nitroConfig?.vercel?.functions?.runtime ?? "nodejs24.x",
|
|
706
|
+
...nitroConfig?.vercel?.functions
|
|
707
|
+
}
|
|
708
|
+
},
|
|
709
|
+
output: {
|
|
710
|
+
...nitroConfig?.output,
|
|
711
|
+
dir: normalizePath(resolve(workspaceRoot, ".vercel", "output")),
|
|
712
|
+
publicDir: normalizePath(resolve(workspaceRoot, ".vercel", "output/static"))
|
|
713
|
+
}
|
|
656
714
|
});
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
...nitroConfig,
|
|
665
|
-
output: {
|
|
666
|
-
...nitroConfig?.output,
|
|
667
|
-
serverDir: '{{ output.publicDir }}/_worker.js',
|
|
668
|
-
},
|
|
715
|
+
var isCloudflarePreset = (buildPreset) => process.env["CF_PAGES"] || buildPreset && (buildPreset.toLowerCase().includes("cloudflare-pages") || buildPreset.toLowerCase().includes("cloudflare_pages"));
|
|
716
|
+
var withCloudflareOutput = (nitroConfig) => ({
|
|
717
|
+
...nitroConfig,
|
|
718
|
+
output: {
|
|
719
|
+
...nitroConfig?.output,
|
|
720
|
+
serverDir: "{{ output.publicDir }}/_worker.js"
|
|
721
|
+
}
|
|
669
722
|
});
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
};
|
|
723
|
+
var isFirebaseAppHosting = () => !!process.env["NG_BUILD_LOGS_JSON"];
|
|
724
|
+
var withAppHostingOutput = (nitroConfig) => {
|
|
725
|
+
let hasOutput = false;
|
|
726
|
+
return {
|
|
727
|
+
...nitroConfig,
|
|
728
|
+
serveStatic: true,
|
|
729
|
+
rollupConfig: {
|
|
730
|
+
...nitroConfig.rollupConfig,
|
|
731
|
+
output: {
|
|
732
|
+
...nitroConfig.rollupConfig?.output,
|
|
733
|
+
entryFileNames: "server.mjs"
|
|
734
|
+
}
|
|
735
|
+
},
|
|
736
|
+
hooks: {
|
|
737
|
+
...nitroConfig.hooks,
|
|
738
|
+
compiled: () => {
|
|
739
|
+
if (!hasOutput) {
|
|
740
|
+
const buildOutput = {
|
|
741
|
+
errors: [],
|
|
742
|
+
warnings: [],
|
|
743
|
+
outputPaths: {
|
|
744
|
+
root: pathToFileURL(`${nitroConfig.output?.dir}`),
|
|
745
|
+
browser: pathToFileURL(`${nitroConfig.output?.publicDir}`),
|
|
746
|
+
server: pathToFileURL(`${nitroConfig.output?.dir}/server`)
|
|
747
|
+
}
|
|
748
|
+
};
|
|
749
|
+
console.log(JSON.stringify(buildOutput, null, 2));
|
|
750
|
+
hasOutput = true;
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
};
|
|
703
755
|
};
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
},
|
|
756
|
+
var isNetlifyPreset = (buildPreset) => process.env["NETLIFY"] || buildPreset && buildPreset.toLowerCase().includes("netlify");
|
|
757
|
+
var withNetlifyOutputAPI = (nitroConfig, workspaceRoot) => ({
|
|
758
|
+
...nitroConfig,
|
|
759
|
+
output: {
|
|
760
|
+
...nitroConfig?.output,
|
|
761
|
+
dir: normalizePath(resolve(workspaceRoot, "netlify/functions"))
|
|
762
|
+
}
|
|
712
763
|
});
|
|
764
|
+
//#endregion
|
|
765
|
+
export { nitro };
|
|
766
|
+
|
|
713
767
|
//# sourceMappingURL=vite-plugin-nitro.js.map
|