@xfe-repo/web-app 2.0.0-beta.1 → 2.0.0-beta.3
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/README.md +60 -2
- package/deploy/.drone.yml +7 -0
- package/deploy/Dockerfile +3 -2
- package/dist/cli.js +486 -187
- package/dist/cli.mjs +475 -175
- package/dist/config.d.mts +11 -1
- package/dist/config.d.ts +11 -1
- package/dist/config.js +68 -10
- package/dist/config.mjs +59 -4
- package/dist/framework.js +88 -44
- package/dist/framework.mjs +47 -3
- package/dist/node-dev.d.mts +2 -0
- package/dist/node-dev.d.ts +2 -0
- package/dist/node-dev.js +356 -0
- package/dist/node-dev.mjs +331 -0
- package/dist/node.d.mts +27 -0
- package/dist/node.d.ts +27 -0
- package/dist/node.js +379 -0
- package/dist/node.mjs +342 -0
- package/dist/react-router-config.js +50 -7
- package/dist/react-router-config.mjs +46 -5
- package/dist/vite.d.mts +1 -0
- package/dist/vite.d.ts +1 -0
- package/dist/vite.js +55 -10
- package/dist/vite.mjs +46 -1
- package/package.json +6 -2
package/dist/node.mjs
ADDED
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
// src/node.ts
|
|
2
|
+
import { once } from "events";
|
|
3
|
+
import { rm } from "fs/promises";
|
|
4
|
+
import { Server } from "http";
|
|
5
|
+
import path3 from "path";
|
|
6
|
+
import { pathToFileURL } from "url";
|
|
7
|
+
import express from "express";
|
|
8
|
+
|
|
9
|
+
// src/config.ts
|
|
10
|
+
import fs from "fs";
|
|
11
|
+
import path from "path";
|
|
12
|
+
import { fileURLToPath } from "url";
|
|
13
|
+
import yaml from "yaml";
|
|
14
|
+
var DEFAULT_BUILD_DIRECTORY = "dist";
|
|
15
|
+
var protectedDirectories = /* @__PURE__ */ new Set(["src", "types", "public", "node_modules", ".git"]);
|
|
16
|
+
var loadXfeConfig = (root = process.cwd()) => {
|
|
17
|
+
const xfeConfigPath = path.join(root, "xfe.json");
|
|
18
|
+
if (!fs.existsSync(xfeConfigPath)) {
|
|
19
|
+
throw new Error("xfe.json \u914D\u7F6E\u6587\u4EF6\u4E0D\u5B58\u5728\uFF0C\u8BF7\u5728\u9879\u76EE\u6839\u76EE\u5F55\u4E0B\u521B\u5EFA\u8BE5\u6587\u4EF6\u3002");
|
|
20
|
+
}
|
|
21
|
+
const xfeConfigContent = fs.readFileSync(xfeConfigPath, "utf8");
|
|
22
|
+
const config = JSON.parse(xfeConfigContent);
|
|
23
|
+
const renderMode = config.webapp?.renderMode;
|
|
24
|
+
if (renderMode !== void 0 && renderMode !== "client" && renderMode !== "server") {
|
|
25
|
+
throw new Error("xfe.json.webapp.renderMode \u53EA\u80FD\u4E3A client \u6216 server");
|
|
26
|
+
}
|
|
27
|
+
getBuildDirectory(root, config.webapp);
|
|
28
|
+
getServerEntry(root, config.webapp);
|
|
29
|
+
return config;
|
|
30
|
+
};
|
|
31
|
+
var getBuildDirectory = (projectRoot, webapp = {}) => {
|
|
32
|
+
const configured = webapp?.buildDirectory === void 0 ? DEFAULT_BUILD_DIRECTORY : webapp.buildDirectory;
|
|
33
|
+
if (typeof configured !== "string" || !configured.trim() || /[\0\r\n]/.test(configured)) {
|
|
34
|
+
throw new Error("xfe.json.webapp.buildDirectory \u5FC5\u987B\u662F\u975E\u7A7A\u7684\u5355\u884C\u5B57\u7B26\u4E32");
|
|
35
|
+
}
|
|
36
|
+
const directory = configured.trim().replaceAll("\\", "/");
|
|
37
|
+
const root = path.resolve(projectRoot);
|
|
38
|
+
const output = path.resolve(root, directory);
|
|
39
|
+
const relative = path.relative(root, output);
|
|
40
|
+
const [firstDirectory = ""] = relative.split(path.sep);
|
|
41
|
+
const escapesProject = path.isAbsolute(directory) || Boolean(path.win32.parse(directory).root) || firstDirectory === "..";
|
|
42
|
+
const overwritesInput = !relative || protectedDirectories.has(firstDirectory.toLowerCase());
|
|
43
|
+
if (escapesProject || overwritesInput) {
|
|
44
|
+
throw new Error("xfe.json.webapp.buildDirectory \u5FC5\u987B\u662F\u9879\u76EE\u5185\u72EC\u7ACB\u7684\u8F93\u51FA\u76EE\u5F55\uFF0C\u4E0D\u80FD\u8986\u76D6\u9879\u76EE\u3001\u6E90\u7801\u6216\u4F9D\u8D56");
|
|
45
|
+
}
|
|
46
|
+
let currentDirectory = root;
|
|
47
|
+
for (const segment of relative.split(path.sep)) {
|
|
48
|
+
currentDirectory = path.join(currentDirectory, segment);
|
|
49
|
+
if (fs.lstatSync(currentDirectory, { throwIfNoEntry: false })?.isSymbolicLink()) {
|
|
50
|
+
throw new Error("xfe.json.webapp.buildDirectory \u4E0D\u80FD\u7ECF\u8FC7\u7B26\u53F7\u94FE\u63A5\uFF0C\u4EE5\u514D\u6E05\u7406\u5176\u4ED6\u76EE\u5F55");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return output;
|
|
54
|
+
};
|
|
55
|
+
var getServerEntry = (projectRoot, webapp = {}) => {
|
|
56
|
+
const entry = webapp?.serverEntry;
|
|
57
|
+
if (entry === void 0) return;
|
|
58
|
+
if (typeof entry !== "string" || !entry.trim() || /[\0\r\n]/.test(entry)) {
|
|
59
|
+
throw new Error("xfe.json.webapp.serverEntry \u5FC5\u987B\u662F\u9879\u76EE\u5185\u7684 TypeScript / JavaScript \u76F8\u5BF9\u8DEF\u5F84");
|
|
60
|
+
}
|
|
61
|
+
const normalized = entry.trim().replaceAll("\\", "/");
|
|
62
|
+
const absolute = path.resolve(projectRoot, normalized);
|
|
63
|
+
const relative = path.relative(path.resolve(projectRoot), absolute);
|
|
64
|
+
const outside = Boolean(path.win32.parse(normalized).root) || relative.split(path.sep)[0] === "..";
|
|
65
|
+
if (outside || !/\.(?:[jt]sx?|m[jt]s)$/.test(relative)) {
|
|
66
|
+
throw new Error("xfe.json.webapp.serverEntry \u5FC5\u987B\u662F\u9879\u76EE\u5185\u7684 TypeScript / JavaScript \u76F8\u5BF9\u8DEF\u5F84");
|
|
67
|
+
}
|
|
68
|
+
return absolute;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// src/framework.ts
|
|
72
|
+
import fs2 from "fs";
|
|
73
|
+
import { createRequire } from "module";
|
|
74
|
+
import path2 from "path";
|
|
75
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
76
|
+
var frameworkDirectory = typeof __dirname === "string" ? __dirname : path2.dirname(fileURLToPath2(import.meta.url));
|
|
77
|
+
var requireFromFramework = createRequire(path2.join(frameworkDirectory, "framework.js"));
|
|
78
|
+
var extensions = [".tsx", ".ts", ".jsx", ".js"];
|
|
79
|
+
var findSource = (directory, name) => extensions.map((extension) => path2.join(directory, `${name}${extension}`)).find(fs2.existsSync);
|
|
80
|
+
var findValueExports = (file) => [...fs2.readFileSync(file, "utf8").matchAll(/^\s*export\s+(?:async\s+)?(?:const|let|var|function|class)\s+([A-Za-z_$][\w$]*)/gm)].map(
|
|
81
|
+
([, name]) => name
|
|
82
|
+
);
|
|
83
|
+
var importPath = (from, target) => {
|
|
84
|
+
const relative = path2.relative(from, target).replace(path2.extname(target), "").replaceAll(path2.sep, "/");
|
|
85
|
+
return relative.startsWith(".") ? relative : `./${relative}`;
|
|
86
|
+
};
|
|
87
|
+
var writeGenerated = (file, content) => {
|
|
88
|
+
if (fs2.existsSync(file) && fs2.readFileSync(file, "utf8") === content) return;
|
|
89
|
+
fs2.writeFileSync(file, content);
|
|
90
|
+
};
|
|
91
|
+
var defaultRootSource = (projectRoot, appDirectory) => {
|
|
92
|
+
const { webapp = {} } = loadXfeConfig(projectRoot);
|
|
93
|
+
const layoutSource = findSource(path2.join(projectRoot, "src"), "layout");
|
|
94
|
+
const layoutExports = layoutSource ? findValueExports(layoutSource) : [];
|
|
95
|
+
const hasErrorView = layoutExports.includes("ErrorView");
|
|
96
|
+
const layoutImport = layoutSource ? `import AppLayout${hasErrorView ? ", { ErrorView }" : ""} from ${JSON.stringify(importPath(appDirectory, layoutSource))}
|
|
97
|
+
` : "";
|
|
98
|
+
return `import { createElement, type ReactNode } from 'react'
|
|
99
|
+
import { Outlet } from 'react-router'
|
|
100
|
+
import { Document, PageError, PageLoading } from '@xfe-repo/web-app/dist/root.mjs'
|
|
101
|
+
${layoutImport}
|
|
102
|
+
export const meta = () => [{ title: ${JSON.stringify(webapp.title || "XFE App")} }]
|
|
103
|
+
export const Layout = ({ children }: { children: ReactNode }) => createElement(Document, { children, lang: ${JSON.stringify(webapp.lang || "zh-CN")}, themeColor: ${JSON.stringify(webapp.themeColor)} })
|
|
104
|
+
export default function Root() { return ${layoutSource ? "createElement(AppLayout, { children: createElement(Outlet) })" : "createElement(Outlet)"} }
|
|
105
|
+
export function ErrorBoundary() { return createElement(PageError, { ${hasErrorView ? "view: ErrorView" : ""} }) }
|
|
106
|
+
export function HydrateFallback() { return createElement(PageLoading) }
|
|
107
|
+
`;
|
|
108
|
+
};
|
|
109
|
+
var getFrameworkRoot = (projectRoot) => path2.join(projectRoot, "node_modules/.cache/xfe-web/react-router");
|
|
110
|
+
var prepareFramework = (projectRoot = process.cwd()) => {
|
|
111
|
+
const sourceDirectory = path2.join(projectRoot, "src");
|
|
112
|
+
const rootSource = findSource(sourceDirectory, "root");
|
|
113
|
+
const appServerSource = findSource(sourceDirectory, "app.server");
|
|
114
|
+
const pagesSource = path2.join(sourceDirectory, "pages");
|
|
115
|
+
if (!fs2.existsSync(pagesSource)) throw new Error("\u672A\u627E\u5230 src/pages");
|
|
116
|
+
const rootDirectory = getFrameworkRoot(projectRoot);
|
|
117
|
+
const appDirectory = path2.join(rootDirectory, "app");
|
|
118
|
+
fs2.mkdirSync(appDirectory, { recursive: true });
|
|
119
|
+
const routerDirectory = path2.dirname(requireFromFramework.resolve("react-router/package.json"));
|
|
120
|
+
const routerLink = path2.join(rootDirectory, "node_modules/react-router");
|
|
121
|
+
fs2.mkdirSync(path2.dirname(routerLink), { recursive: true });
|
|
122
|
+
if (!fs2.lstatSync(routerLink, { throwIfNoEntry: false })?.isSymbolicLink() || fs2.readlinkSync(routerLink) !== routerDirectory) {
|
|
123
|
+
fs2.rmSync(routerLink, { force: true });
|
|
124
|
+
fs2.symlinkSync(routerDirectory, routerLink, "junction");
|
|
125
|
+
}
|
|
126
|
+
const rootTarget = path2.join(appDirectory, "root.tsx");
|
|
127
|
+
const rootImport = rootSource ? importPath(appDirectory, rootSource) : "";
|
|
128
|
+
const rootExports = rootSource ? findValueExports(rootSource).filter((name) => name !== "middleware" || !appServerSource) : [];
|
|
129
|
+
const namedExports = rootExports.length ? `export { ${rootExports.join(", ")} } from ${JSON.stringify(rootImport)}
|
|
130
|
+
` : "";
|
|
131
|
+
const errorBoundaryExport = rootExports.includes("ErrorBoundary") ? "" : "export { DefaultErrorBoundary as ErrorBoundary } from '@xfe-repo/web-router/errors'\n";
|
|
132
|
+
const middlewareExport = appServerSource ? `export { middleware } from ${JSON.stringify(importPath(appDirectory, appServerSource))}
|
|
133
|
+
` : "";
|
|
134
|
+
writeGenerated(
|
|
135
|
+
rootTarget,
|
|
136
|
+
rootSource ? `export * from ${JSON.stringify(rootImport)}
|
|
137
|
+
export { default } from ${JSON.stringify(rootImport)}
|
|
138
|
+
${namedExports}${errorBoundaryExport}${middlewareExport}` : `${defaultRootSource(projectRoot, appDirectory)}${middlewareExport}`
|
|
139
|
+
);
|
|
140
|
+
const pagesLink = path2.join(appDirectory, "pages");
|
|
141
|
+
if (!fs2.existsSync(pagesLink)) fs2.symlinkSync(path2.relative(appDirectory, pagesSource), pagesLink, "dir");
|
|
142
|
+
writeGenerated(
|
|
143
|
+
path2.join(rootDirectory, "react-router.config.js"),
|
|
144
|
+
"export { default } from '@xfe-repo/web-app/dist/react-router-config.mjs'\n"
|
|
145
|
+
);
|
|
146
|
+
writeGenerated(
|
|
147
|
+
path2.join(appDirectory, "routes.js"),
|
|
148
|
+
`import { collectPageRoutes } from '@xfe-repo/web-router/routes'
|
|
149
|
+
export default collectPageRoutes(${JSON.stringify(appDirectory)})
|
|
150
|
+
`
|
|
151
|
+
);
|
|
152
|
+
const defaultsDirectory = path2.join(path2.dirname(requireFromFramework.resolve("@react-router/dev/package.json")), "dist/config/defaults");
|
|
153
|
+
writeGenerated(
|
|
154
|
+
path2.join(appDirectory, "entry.server.tsx"),
|
|
155
|
+
`export { default, streamTimeout } from ${JSON.stringify(importPath(appDirectory, path2.join(defaultsDirectory, "entry.server.web.tsx")))}
|
|
156
|
+
`
|
|
157
|
+
);
|
|
158
|
+
const typeScriptConfig = path2.join(rootDirectory, "tsconfig.json");
|
|
159
|
+
writeGenerated(
|
|
160
|
+
typeScriptConfig,
|
|
161
|
+
JSON.stringify(
|
|
162
|
+
{
|
|
163
|
+
extends: path2.join(projectRoot, "tsconfig.json"),
|
|
164
|
+
compilerOptions: { rootDirs: [projectRoot, rootDirectory, path2.join(rootDirectory, ".react-router/types")] },
|
|
165
|
+
include: [
|
|
166
|
+
path2.join(sourceDirectory, "**/*"),
|
|
167
|
+
path2.join(projectRoot, "types/**/*"),
|
|
168
|
+
path2.join(appDirectory, "*.tsx"),
|
|
169
|
+
path2.join(rootDirectory, ".react-router/types/**/*")
|
|
170
|
+
],
|
|
171
|
+
exclude: []
|
|
172
|
+
},
|
|
173
|
+
null,
|
|
174
|
+
2
|
|
175
|
+
)
|
|
176
|
+
);
|
|
177
|
+
return {
|
|
178
|
+
appDirectory,
|
|
179
|
+
rootDirectory,
|
|
180
|
+
viteConfig: path2.resolve(frameworkDirectory, "vite.mjs"),
|
|
181
|
+
typeScriptConfig
|
|
182
|
+
};
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
// src/node.ts
|
|
186
|
+
var NODE_OUTPUT = "server/node.mjs";
|
|
187
|
+
var HMR_PATH = "/_xfe/hmr";
|
|
188
|
+
var SHUTDOWN_TIMEOUT = 3e4;
|
|
189
|
+
async function buildNode({ projectRoot, webapp }) {
|
|
190
|
+
const { build } = await import("esbuild");
|
|
191
|
+
const entry = getServerEntry(projectRoot, webapp);
|
|
192
|
+
if (!entry) throw new Error("\u7F3A\u5C11 xfe.json.webapp.serverEntry");
|
|
193
|
+
if (webapp.renderMode === "client") await rm(path3.join(getBuildDirectory(projectRoot, webapp), "server"), { recursive: true, force: true });
|
|
194
|
+
await build({
|
|
195
|
+
absWorkingDir: projectRoot,
|
|
196
|
+
entryPoints: [entry],
|
|
197
|
+
outfile: path3.join(getBuildDirectory(projectRoot, webapp), NODE_OUTPUT),
|
|
198
|
+
tsconfig: path3.join(projectRoot, "tsconfig.json"),
|
|
199
|
+
bundle: true,
|
|
200
|
+
packages: "external",
|
|
201
|
+
platform: "node",
|
|
202
|
+
format: "esm",
|
|
203
|
+
target: "node22.22",
|
|
204
|
+
sourcemap: true
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
async function runNode({ projectRoot, webapp, development }) {
|
|
208
|
+
const entry = development ? getServerEntry(projectRoot, webapp) : path3.join(getBuildDirectory(projectRoot, webapp), NODE_OUTPUT);
|
|
209
|
+
if (!entry) throw new Error("\u7F3A\u5C11 xfe.json.webapp.serverEntry");
|
|
210
|
+
if (development) {
|
|
211
|
+
const { loadEnv } = await import("vite");
|
|
212
|
+
Object.assign(process.env, { ...loadEnv("development", projectRoot, ""), ...process.env });
|
|
213
|
+
} else process.env.NODE_ENV ??= "production";
|
|
214
|
+
const module = await import(pathToFileURL(entry).href);
|
|
215
|
+
if (typeof module.default !== "function") throw new Error("serverEntry \u5FC5\u987B\u9ED8\u8BA4\u5BFC\u51FA Node \u670D\u52A1\u5DE5\u5382\u51FD\u6570");
|
|
216
|
+
const frontend = express().disable("x-powered-by");
|
|
217
|
+
const application = await module.default({ frontend, mode: development ? "development" : "production" });
|
|
218
|
+
const upgrades = /* @__PURE__ */ new Set();
|
|
219
|
+
let vite;
|
|
220
|
+
let closing;
|
|
221
|
+
const close = () => closing ??= disposeApplication(application, { vite, upgrades });
|
|
222
|
+
const onSignal = async () => {
|
|
223
|
+
try {
|
|
224
|
+
await close();
|
|
225
|
+
} catch (error) {
|
|
226
|
+
console.error("XFE Node \u5173\u95ED\u5931\u8D25:", error);
|
|
227
|
+
process.exit(1);
|
|
228
|
+
} finally {
|
|
229
|
+
process.off("SIGINT", onSignal);
|
|
230
|
+
process.off("SIGTERM", onSignal);
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
try {
|
|
234
|
+
const server = application?.server;
|
|
235
|
+
if (!(server instanceof Server) || server.listening) throw new Error("Node \u5DE5\u5382\u5FC5\u987B\u8FD4\u56DE\u5C1A\u672A listen \u7684 http.Server");
|
|
236
|
+
if (server.listenerCount("upgrade")) throw new Error("\u8BF7\u901A\u8FC7\u5DE5\u5382\u8FD4\u56DE\u7684 upgrade \u5904\u7406\u5347\u7EA7\uFF0C\u4E0D\u8981\u76F4\u63A5\u6CE8\u518C server \u7684 upgrade \u4E8B\u4EF6");
|
|
237
|
+
const hmrPath = path3.posix.join(webapp.basename || "/", HMR_PATH);
|
|
238
|
+
server.on(
|
|
239
|
+
"upgrade",
|
|
240
|
+
/** HMR 与业务互斥分流,升级连接由关闭流程统一回收。 */
|
|
241
|
+
(request, socket, head) => {
|
|
242
|
+
upgrades.add(socket);
|
|
243
|
+
socket.once(
|
|
244
|
+
"close",
|
|
245
|
+
/** 不保留已经断开的升级连接。 */
|
|
246
|
+
() => upgrades.delete(socket)
|
|
247
|
+
);
|
|
248
|
+
if (development && request.url?.split("?")[0] === hmrPath) {
|
|
249
|
+
if (!["vite-hmr", "vite-ping"].includes(String(request.headers["sec-websocket-protocol"]))) socket.destroy();
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
if (application.upgrade) application.upgrade(request, socket, head);
|
|
253
|
+
else socket.destroy();
|
|
254
|
+
}
|
|
255
|
+
);
|
|
256
|
+
if (development) vite = await createDevelopmentServer(server, projectRoot);
|
|
257
|
+
await mountFrontend(frontend, { projectRoot, webapp, vite });
|
|
258
|
+
const listening = once(server, "listening");
|
|
259
|
+
const host = process.env.HOST || webapp.host || "0.0.0.0";
|
|
260
|
+
const port = Number(process.env.PORT ?? webapp.port ?? 3e3);
|
|
261
|
+
server.listen(port, host);
|
|
262
|
+
await listening;
|
|
263
|
+
console.info(`XFE Node: http://${host}:${port}`);
|
|
264
|
+
process.on("SIGINT", onSignal);
|
|
265
|
+
process.on("SIGTERM", onSignal);
|
|
266
|
+
} catch (error) {
|
|
267
|
+
await close();
|
|
268
|
+
throw error;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
async function createDevelopmentServer(server, projectRoot) {
|
|
272
|
+
const { createServer } = await import("vite");
|
|
273
|
+
const framework = prepareFramework(projectRoot);
|
|
274
|
+
const events = [[process, "SIGINT"], [process, "SIGTERM"], [process.stdin, "end"]];
|
|
275
|
+
const snapshots = events.map(
|
|
276
|
+
/** 只记录当前监听,恢复时保留宿主和业务原有的处理器。 */
|
|
277
|
+
([source, event]) => ({ source, event, listeners: new Set(source.listeners(event)) })
|
|
278
|
+
);
|
|
279
|
+
try {
|
|
280
|
+
return await createServer({
|
|
281
|
+
root: framework.rootDirectory,
|
|
282
|
+
configFile: framework.viteConfig,
|
|
283
|
+
server: { middlewareMode: true, ws: { server, path: HMR_PATH } },
|
|
284
|
+
appType: "custom"
|
|
285
|
+
});
|
|
286
|
+
} finally {
|
|
287
|
+
for (const { source, event, listeners } of snapshots) {
|
|
288
|
+
for (const listener of source.listeners(event)) {
|
|
289
|
+
if (!listeners.has(listener)) source.removeListener(event, listener);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
async function mountFrontend(frontend, { projectRoot, webapp, vite }) {
|
|
295
|
+
let build;
|
|
296
|
+
if (vite) {
|
|
297
|
+
const { isRunnableDevEnvironment } = await import("vite");
|
|
298
|
+
const environment = vite.environments.ssr;
|
|
299
|
+
if (!isRunnableDevEnvironment(environment)) throw new Error("React Router \u5F00\u53D1\u73AF\u5883\u672A\u5C31\u7EEA");
|
|
300
|
+
frontend.use(vite.middlewares);
|
|
301
|
+
build = async () => environment.runner.import("virtual:react-router/server-build");
|
|
302
|
+
} else {
|
|
303
|
+
const directory = getBuildDirectory(projectRoot, webapp);
|
|
304
|
+
const basename = webapp.basename || "/";
|
|
305
|
+
frontend.use(path3.posix.join(basename, "assets"), express.static(path3.join(directory, "client/assets"), { immutable: true, maxAge: "1y", fallthrough: false }));
|
|
306
|
+
frontend.use(basename, express.static(path3.join(directory, "client")));
|
|
307
|
+
if (webapp.renderMode === "client") {
|
|
308
|
+
frontend.get(
|
|
309
|
+
path3.posix.join(basename, "{*path}"),
|
|
310
|
+
/** SPA 深链接始终返回构建后的首页。 */
|
|
311
|
+
(_request, response) => response.sendFile(path3.join(directory, "client/index.html"))
|
|
312
|
+
);
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
build = await import(pathToFileURL(path3.join(directory, "server/index.js")).href);
|
|
316
|
+
}
|
|
317
|
+
const { createRequestHandler } = await import("@react-router/express");
|
|
318
|
+
frontend.use(createRequestHandler({ build, mode: vite ? "development" : "production" }));
|
|
319
|
+
}
|
|
320
|
+
async function disposeApplication(application, { vite, upgrades }) {
|
|
321
|
+
const server = application?.server instanceof Server ? application.server : void 0;
|
|
322
|
+
const forced = setTimeout(
|
|
323
|
+
/** 生产关闭时中断超过等待上限的普通 HTTP 请求。 */
|
|
324
|
+
() => server?.closeAllConnections(),
|
|
325
|
+
SHUTDOWN_TIMEOUT
|
|
326
|
+
);
|
|
327
|
+
forced.unref();
|
|
328
|
+
try {
|
|
329
|
+
const drained = server?.listening ? server[Symbol.asyncDispose]() : void 0;
|
|
330
|
+
for (const socket of upgrades) socket.destroy();
|
|
331
|
+
const results = await Promise.allSettled([drained, vite?.close()]);
|
|
332
|
+
await application?.close?.();
|
|
333
|
+
const failure = results.find((result) => result.status === "rejected");
|
|
334
|
+
if (failure?.status === "rejected") throw failure.reason;
|
|
335
|
+
} finally {
|
|
336
|
+
clearTimeout(forced);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
export {
|
|
340
|
+
buildNode,
|
|
341
|
+
runNode
|
|
342
|
+
};
|
|
@@ -33,25 +33,68 @@ __export(react_router_config_exports, {
|
|
|
33
33
|
default: () => react_router_config_default
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(react_router_config_exports);
|
|
36
|
-
var import_node_path = __toESM(require("path"));
|
|
37
36
|
|
|
38
37
|
// src/config.ts
|
|
39
|
-
var
|
|
40
|
-
var
|
|
38
|
+
var import_node_fs = __toESM(require("fs"));
|
|
39
|
+
var import_node_path = __toESM(require("path"));
|
|
40
|
+
var import_node_url = require("url");
|
|
41
41
|
var import_yaml = __toESM(require("yaml"));
|
|
42
|
+
var DEFAULT_BUILD_DIRECTORY = "dist";
|
|
43
|
+
var protectedDirectories = /* @__PURE__ */ new Set(["src", "types", "public", "node_modules", ".git"]);
|
|
42
44
|
var loadXfeConfig = (root = process.cwd()) => {
|
|
43
|
-
const xfeConfigPath =
|
|
44
|
-
if (!
|
|
45
|
+
const xfeConfigPath = import_node_path.default.join(root, "xfe.json");
|
|
46
|
+
if (!import_node_fs.default.existsSync(xfeConfigPath)) {
|
|
45
47
|
throw new Error("xfe.json \u914D\u7F6E\u6587\u4EF6\u4E0D\u5B58\u5728\uFF0C\u8BF7\u5728\u9879\u76EE\u6839\u76EE\u5F55\u4E0B\u521B\u5EFA\u8BE5\u6587\u4EF6\u3002");
|
|
46
48
|
}
|
|
47
|
-
const xfeConfigContent =
|
|
49
|
+
const xfeConfigContent = import_node_fs.default.readFileSync(xfeConfigPath, "utf8");
|
|
48
50
|
const config = JSON.parse(xfeConfigContent);
|
|
49
51
|
const renderMode = config.webapp?.renderMode;
|
|
50
52
|
if (renderMode !== void 0 && renderMode !== "client" && renderMode !== "server") {
|
|
51
53
|
throw new Error("xfe.json.webapp.renderMode \u53EA\u80FD\u4E3A client \u6216 server");
|
|
52
54
|
}
|
|
55
|
+
getBuildDirectory(root, config.webapp);
|
|
56
|
+
getServerEntry(root, config.webapp);
|
|
53
57
|
return config;
|
|
54
58
|
};
|
|
59
|
+
var getBuildDirectory = (projectRoot2, webapp2 = {}) => {
|
|
60
|
+
const configured = webapp2?.buildDirectory === void 0 ? DEFAULT_BUILD_DIRECTORY : webapp2.buildDirectory;
|
|
61
|
+
if (typeof configured !== "string" || !configured.trim() || /[\0\r\n]/.test(configured)) {
|
|
62
|
+
throw new Error("xfe.json.webapp.buildDirectory \u5FC5\u987B\u662F\u975E\u7A7A\u7684\u5355\u884C\u5B57\u7B26\u4E32");
|
|
63
|
+
}
|
|
64
|
+
const directory = configured.trim().replaceAll("\\", "/");
|
|
65
|
+
const root = import_node_path.default.resolve(projectRoot2);
|
|
66
|
+
const output = import_node_path.default.resolve(root, directory);
|
|
67
|
+
const relative = import_node_path.default.relative(root, output);
|
|
68
|
+
const [firstDirectory = ""] = relative.split(import_node_path.default.sep);
|
|
69
|
+
const escapesProject = import_node_path.default.isAbsolute(directory) || Boolean(import_node_path.default.win32.parse(directory).root) || firstDirectory === "..";
|
|
70
|
+
const overwritesInput = !relative || protectedDirectories.has(firstDirectory.toLowerCase());
|
|
71
|
+
if (escapesProject || overwritesInput) {
|
|
72
|
+
throw new Error("xfe.json.webapp.buildDirectory \u5FC5\u987B\u662F\u9879\u76EE\u5185\u72EC\u7ACB\u7684\u8F93\u51FA\u76EE\u5F55\uFF0C\u4E0D\u80FD\u8986\u76D6\u9879\u76EE\u3001\u6E90\u7801\u6216\u4F9D\u8D56");
|
|
73
|
+
}
|
|
74
|
+
let currentDirectory = root;
|
|
75
|
+
for (const segment of relative.split(import_node_path.default.sep)) {
|
|
76
|
+
currentDirectory = import_node_path.default.join(currentDirectory, segment);
|
|
77
|
+
if (import_node_fs.default.lstatSync(currentDirectory, { throwIfNoEntry: false })?.isSymbolicLink()) {
|
|
78
|
+
throw new Error("xfe.json.webapp.buildDirectory \u4E0D\u80FD\u7ECF\u8FC7\u7B26\u53F7\u94FE\u63A5\uFF0C\u4EE5\u514D\u6E05\u7406\u5176\u4ED6\u76EE\u5F55");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return output;
|
|
82
|
+
};
|
|
83
|
+
var getServerEntry = (projectRoot2, webapp2 = {}) => {
|
|
84
|
+
const entry = webapp2?.serverEntry;
|
|
85
|
+
if (entry === void 0) return;
|
|
86
|
+
if (typeof entry !== "string" || !entry.trim() || /[\0\r\n]/.test(entry)) {
|
|
87
|
+
throw new Error("xfe.json.webapp.serverEntry \u5FC5\u987B\u662F\u9879\u76EE\u5185\u7684 TypeScript / JavaScript \u76F8\u5BF9\u8DEF\u5F84");
|
|
88
|
+
}
|
|
89
|
+
const normalized = entry.trim().replaceAll("\\", "/");
|
|
90
|
+
const absolute = import_node_path.default.resolve(projectRoot2, normalized);
|
|
91
|
+
const relative = import_node_path.default.relative(import_node_path.default.resolve(projectRoot2), absolute);
|
|
92
|
+
const outside = Boolean(import_node_path.default.win32.parse(normalized).root) || relative.split(import_node_path.default.sep)[0] === "..";
|
|
93
|
+
if (outside || !/\.(?:[jt]sx?|m[jt]s)$/.test(relative)) {
|
|
94
|
+
throw new Error("xfe.json.webapp.serverEntry \u5FC5\u987B\u662F\u9879\u76EE\u5185\u7684 TypeScript / JavaScript \u76F8\u5BF9\u8DEF\u5F84");
|
|
95
|
+
}
|
|
96
|
+
return absolute;
|
|
97
|
+
};
|
|
55
98
|
|
|
56
99
|
// src/react-router-config.ts
|
|
57
100
|
var projectRoot = process.env.XFE_WEB_ROOT;
|
|
@@ -60,7 +103,7 @@ var { webapp = {} } = loadXfeConfig(projectRoot);
|
|
|
60
103
|
var react_router_config_default = {
|
|
61
104
|
appDirectory: "app",
|
|
62
105
|
basename: webapp.basename || "/",
|
|
63
|
-
buildDirectory:
|
|
106
|
+
buildDirectory: getBuildDirectory(projectRoot, webapp),
|
|
64
107
|
future: { unstable_optimizeDeps: true },
|
|
65
108
|
ssr: webapp.renderMode !== "client"
|
|
66
109
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
// src/react-router-config.ts
|
|
2
|
-
import path2 from "path";
|
|
3
|
-
|
|
4
1
|
// src/config.ts
|
|
5
|
-
import path from "path";
|
|
6
2
|
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
7
5
|
import yaml from "yaml";
|
|
6
|
+
var DEFAULT_BUILD_DIRECTORY = "dist";
|
|
7
|
+
var protectedDirectories = /* @__PURE__ */ new Set(["src", "types", "public", "node_modules", ".git"]);
|
|
8
8
|
var loadXfeConfig = (root = process.cwd()) => {
|
|
9
9
|
const xfeConfigPath = path.join(root, "xfe.json");
|
|
10
10
|
if (!fs.existsSync(xfeConfigPath)) {
|
|
@@ -16,8 +16,49 @@ var loadXfeConfig = (root = process.cwd()) => {
|
|
|
16
16
|
if (renderMode !== void 0 && renderMode !== "client" && renderMode !== "server") {
|
|
17
17
|
throw new Error("xfe.json.webapp.renderMode \u53EA\u80FD\u4E3A client \u6216 server");
|
|
18
18
|
}
|
|
19
|
+
getBuildDirectory(root, config.webapp);
|
|
20
|
+
getServerEntry(root, config.webapp);
|
|
19
21
|
return config;
|
|
20
22
|
};
|
|
23
|
+
var getBuildDirectory = (projectRoot2, webapp2 = {}) => {
|
|
24
|
+
const configured = webapp2?.buildDirectory === void 0 ? DEFAULT_BUILD_DIRECTORY : webapp2.buildDirectory;
|
|
25
|
+
if (typeof configured !== "string" || !configured.trim() || /[\0\r\n]/.test(configured)) {
|
|
26
|
+
throw new Error("xfe.json.webapp.buildDirectory \u5FC5\u987B\u662F\u975E\u7A7A\u7684\u5355\u884C\u5B57\u7B26\u4E32");
|
|
27
|
+
}
|
|
28
|
+
const directory = configured.trim().replaceAll("\\", "/");
|
|
29
|
+
const root = path.resolve(projectRoot2);
|
|
30
|
+
const output = path.resolve(root, directory);
|
|
31
|
+
const relative = path.relative(root, output);
|
|
32
|
+
const [firstDirectory = ""] = relative.split(path.sep);
|
|
33
|
+
const escapesProject = path.isAbsolute(directory) || Boolean(path.win32.parse(directory).root) || firstDirectory === "..";
|
|
34
|
+
const overwritesInput = !relative || protectedDirectories.has(firstDirectory.toLowerCase());
|
|
35
|
+
if (escapesProject || overwritesInput) {
|
|
36
|
+
throw new Error("xfe.json.webapp.buildDirectory \u5FC5\u987B\u662F\u9879\u76EE\u5185\u72EC\u7ACB\u7684\u8F93\u51FA\u76EE\u5F55\uFF0C\u4E0D\u80FD\u8986\u76D6\u9879\u76EE\u3001\u6E90\u7801\u6216\u4F9D\u8D56");
|
|
37
|
+
}
|
|
38
|
+
let currentDirectory = root;
|
|
39
|
+
for (const segment of relative.split(path.sep)) {
|
|
40
|
+
currentDirectory = path.join(currentDirectory, segment);
|
|
41
|
+
if (fs.lstatSync(currentDirectory, { throwIfNoEntry: false })?.isSymbolicLink()) {
|
|
42
|
+
throw new Error("xfe.json.webapp.buildDirectory \u4E0D\u80FD\u7ECF\u8FC7\u7B26\u53F7\u94FE\u63A5\uFF0C\u4EE5\u514D\u6E05\u7406\u5176\u4ED6\u76EE\u5F55");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return output;
|
|
46
|
+
};
|
|
47
|
+
var getServerEntry = (projectRoot2, webapp2 = {}) => {
|
|
48
|
+
const entry = webapp2?.serverEntry;
|
|
49
|
+
if (entry === void 0) return;
|
|
50
|
+
if (typeof entry !== "string" || !entry.trim() || /[\0\r\n]/.test(entry)) {
|
|
51
|
+
throw new Error("xfe.json.webapp.serverEntry \u5FC5\u987B\u662F\u9879\u76EE\u5185\u7684 TypeScript / JavaScript \u76F8\u5BF9\u8DEF\u5F84");
|
|
52
|
+
}
|
|
53
|
+
const normalized = entry.trim().replaceAll("\\", "/");
|
|
54
|
+
const absolute = path.resolve(projectRoot2, normalized);
|
|
55
|
+
const relative = path.relative(path.resolve(projectRoot2), absolute);
|
|
56
|
+
const outside = Boolean(path.win32.parse(normalized).root) || relative.split(path.sep)[0] === "..";
|
|
57
|
+
if (outside || !/\.(?:[jt]sx?|m[jt]s)$/.test(relative)) {
|
|
58
|
+
throw new Error("xfe.json.webapp.serverEntry \u5FC5\u987B\u662F\u9879\u76EE\u5185\u7684 TypeScript / JavaScript \u76F8\u5BF9\u8DEF\u5F84");
|
|
59
|
+
}
|
|
60
|
+
return absolute;
|
|
61
|
+
};
|
|
21
62
|
|
|
22
63
|
// src/react-router-config.ts
|
|
23
64
|
var projectRoot = process.env.XFE_WEB_ROOT;
|
|
@@ -26,7 +67,7 @@ var { webapp = {} } = loadXfeConfig(projectRoot);
|
|
|
26
67
|
var react_router_config_default = {
|
|
27
68
|
appDirectory: "app",
|
|
28
69
|
basename: webapp.basename || "/",
|
|
29
|
-
buildDirectory:
|
|
70
|
+
buildDirectory: getBuildDirectory(projectRoot, webapp),
|
|
30
71
|
future: { unstable_optimizeDeps: true },
|
|
31
72
|
ssr: webapp.renderMode !== "client"
|
|
32
73
|
};
|
package/dist/vite.d.mts
CHANGED
|
@@ -4,6 +4,7 @@ declare const adaptPageRoute: (code: string, options: string | {
|
|
|
4
4
|
id: string;
|
|
5
5
|
clientOnly?: boolean;
|
|
6
6
|
}) => string | undefined;
|
|
7
|
+
/** Node 入口按 basename 托管前端,构建与开发必须生成相同前缀的资源 URL。 */
|
|
7
8
|
declare const _default: vite.UserConfigFnObject;
|
|
8
9
|
|
|
9
10
|
export { adaptPageRoute, _default as default };
|
package/dist/vite.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ declare const adaptPageRoute: (code: string, options: string | {
|
|
|
4
4
|
id: string;
|
|
5
5
|
clientOnly?: boolean;
|
|
6
6
|
}) => string | undefined;
|
|
7
|
+
/** Node 入口按 basename 托管前端,构建与开发必须生成相同前缀的资源 URL。 */
|
|
7
8
|
declare const _default: vite.UserConfigFnObject;
|
|
8
9
|
|
|
9
10
|
export { adaptPageRoute, _default as default };
|
package/dist/vite.js
CHANGED
|
@@ -34,28 +34,72 @@ __export(vite_exports, {
|
|
|
34
34
|
default: () => vite_default
|
|
35
35
|
});
|
|
36
36
|
module.exports = __toCommonJS(vite_exports);
|
|
37
|
-
var
|
|
38
|
-
var
|
|
37
|
+
var import_node_path2 = __toESM(require("path"));
|
|
38
|
+
var import_node_fs2 = require("fs");
|
|
39
39
|
var import_vite = require("@react-router/dev/vite");
|
|
40
40
|
var import_vite2 = require("vite");
|
|
41
41
|
|
|
42
42
|
// src/config.ts
|
|
43
|
-
var
|
|
44
|
-
var
|
|
43
|
+
var import_node_fs = __toESM(require("fs"));
|
|
44
|
+
var import_node_path = __toESM(require("path"));
|
|
45
|
+
var import_node_url = require("url");
|
|
45
46
|
var import_yaml = __toESM(require("yaml"));
|
|
47
|
+
var DEFAULT_BUILD_DIRECTORY = "dist";
|
|
48
|
+
var protectedDirectories = /* @__PURE__ */ new Set(["src", "types", "public", "node_modules", ".git"]);
|
|
46
49
|
var loadXfeConfig = (root = process.cwd()) => {
|
|
47
|
-
const xfeConfigPath =
|
|
48
|
-
if (!
|
|
50
|
+
const xfeConfigPath = import_node_path.default.join(root, "xfe.json");
|
|
51
|
+
if (!import_node_fs.default.existsSync(xfeConfigPath)) {
|
|
49
52
|
throw new Error("xfe.json \u914D\u7F6E\u6587\u4EF6\u4E0D\u5B58\u5728\uFF0C\u8BF7\u5728\u9879\u76EE\u6839\u76EE\u5F55\u4E0B\u521B\u5EFA\u8BE5\u6587\u4EF6\u3002");
|
|
50
53
|
}
|
|
51
|
-
const xfeConfigContent =
|
|
54
|
+
const xfeConfigContent = import_node_fs.default.readFileSync(xfeConfigPath, "utf8");
|
|
52
55
|
const config = JSON.parse(xfeConfigContent);
|
|
53
56
|
const renderMode = config.webapp?.renderMode;
|
|
54
57
|
if (renderMode !== void 0 && renderMode !== "client" && renderMode !== "server") {
|
|
55
58
|
throw new Error("xfe.json.webapp.renderMode \u53EA\u80FD\u4E3A client \u6216 server");
|
|
56
59
|
}
|
|
60
|
+
getBuildDirectory(root, config.webapp);
|
|
61
|
+
getServerEntry(root, config.webapp);
|
|
57
62
|
return config;
|
|
58
63
|
};
|
|
64
|
+
var getBuildDirectory = (projectRoot, webapp = {}) => {
|
|
65
|
+
const configured = webapp?.buildDirectory === void 0 ? DEFAULT_BUILD_DIRECTORY : webapp.buildDirectory;
|
|
66
|
+
if (typeof configured !== "string" || !configured.trim() || /[\0\r\n]/.test(configured)) {
|
|
67
|
+
throw new Error("xfe.json.webapp.buildDirectory \u5FC5\u987B\u662F\u975E\u7A7A\u7684\u5355\u884C\u5B57\u7B26\u4E32");
|
|
68
|
+
}
|
|
69
|
+
const directory = configured.trim().replaceAll("\\", "/");
|
|
70
|
+
const root = import_node_path.default.resolve(projectRoot);
|
|
71
|
+
const output = import_node_path.default.resolve(root, directory);
|
|
72
|
+
const relative = import_node_path.default.relative(root, output);
|
|
73
|
+
const [firstDirectory = ""] = relative.split(import_node_path.default.sep);
|
|
74
|
+
const escapesProject = import_node_path.default.isAbsolute(directory) || Boolean(import_node_path.default.win32.parse(directory).root) || firstDirectory === "..";
|
|
75
|
+
const overwritesInput = !relative || protectedDirectories.has(firstDirectory.toLowerCase());
|
|
76
|
+
if (escapesProject || overwritesInput) {
|
|
77
|
+
throw new Error("xfe.json.webapp.buildDirectory \u5FC5\u987B\u662F\u9879\u76EE\u5185\u72EC\u7ACB\u7684\u8F93\u51FA\u76EE\u5F55\uFF0C\u4E0D\u80FD\u8986\u76D6\u9879\u76EE\u3001\u6E90\u7801\u6216\u4F9D\u8D56");
|
|
78
|
+
}
|
|
79
|
+
let currentDirectory = root;
|
|
80
|
+
for (const segment of relative.split(import_node_path.default.sep)) {
|
|
81
|
+
currentDirectory = import_node_path.default.join(currentDirectory, segment);
|
|
82
|
+
if (import_node_fs.default.lstatSync(currentDirectory, { throwIfNoEntry: false })?.isSymbolicLink()) {
|
|
83
|
+
throw new Error("xfe.json.webapp.buildDirectory \u4E0D\u80FD\u7ECF\u8FC7\u7B26\u53F7\u94FE\u63A5\uFF0C\u4EE5\u514D\u6E05\u7406\u5176\u4ED6\u76EE\u5F55");
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return output;
|
|
87
|
+
};
|
|
88
|
+
var getServerEntry = (projectRoot, webapp = {}) => {
|
|
89
|
+
const entry = webapp?.serverEntry;
|
|
90
|
+
if (entry === void 0) return;
|
|
91
|
+
if (typeof entry !== "string" || !entry.trim() || /[\0\r\n]/.test(entry)) {
|
|
92
|
+
throw new Error("xfe.json.webapp.serverEntry \u5FC5\u987B\u662F\u9879\u76EE\u5185\u7684 TypeScript / JavaScript \u76F8\u5BF9\u8DEF\u5F84");
|
|
93
|
+
}
|
|
94
|
+
const normalized = entry.trim().replaceAll("\\", "/");
|
|
95
|
+
const absolute = import_node_path.default.resolve(projectRoot, normalized);
|
|
96
|
+
const relative = import_node_path.default.relative(import_node_path.default.resolve(projectRoot), absolute);
|
|
97
|
+
const outside = Boolean(import_node_path.default.win32.parse(normalized).root) || relative.split(import_node_path.default.sep)[0] === "..";
|
|
98
|
+
if (outside || !/\.(?:[jt]sx?|m[jt]s)$/.test(relative)) {
|
|
99
|
+
throw new Error("xfe.json.webapp.serverEntry \u5FC5\u987B\u662F\u9879\u76EE\u5185\u7684 TypeScript / JavaScript \u76F8\u5BF9\u8DEF\u5F84");
|
|
100
|
+
}
|
|
101
|
+
return absolute;
|
|
102
|
+
};
|
|
59
103
|
|
|
60
104
|
// src/vite.ts
|
|
61
105
|
var chromeDevToolsConfigPath = "/.well-known/appspecific/com.chrome.devtools.json";
|
|
@@ -87,11 +131,12 @@ var vite_default = (0, import_vite2.defineConfig)(({ mode }) => {
|
|
|
87
131
|
const { webapp = {} } = loadXfeConfig(projectRoot);
|
|
88
132
|
const publicEnv = (key) => process.env[key] || env[key] || "";
|
|
89
133
|
return {
|
|
134
|
+
...webapp.serverEntry ? { base: import_node_path2.default.posix.join(webapp.basename || "/", "/") } : {},
|
|
90
135
|
plugins: [frameworkPlugin(webapp.renderMode === "client"), (0, import_vite.reactRouter)()],
|
|
91
136
|
build: { emptyOutDir: true },
|
|
92
137
|
envDir: projectRoot,
|
|
93
138
|
envPrefix: ["VITE_", "REACT_APP_"],
|
|
94
|
-
publicDir:
|
|
139
|
+
publicDir: import_node_path2.default.join(projectRoot, "public"),
|
|
95
140
|
define: {
|
|
96
141
|
"import.meta.env.XFE_JWT_AUD": JSON.stringify(publicEnv("XFE_JWT_AUD")),
|
|
97
142
|
"import.meta.env.XFE_JWT_KEY_ID": JSON.stringify(publicEnv("XFE_JWT_KEY_ID")),
|
|
@@ -106,7 +151,7 @@ var vite_default = (0, import_vite2.defineConfig)(({ mode }) => {
|
|
|
106
151
|
preprocessorOptions: {
|
|
107
152
|
less: {
|
|
108
153
|
javascriptEnabled: true,
|
|
109
|
-
paths: [
|
|
154
|
+
paths: [import_node_path2.default.join(projectRoot, "src")]
|
|
110
155
|
}
|
|
111
156
|
}
|
|
112
157
|
},
|
|
@@ -114,7 +159,7 @@ var vite_default = (0, import_vite2.defineConfig)(({ mode }) => {
|
|
|
114
159
|
tsconfigPaths: true,
|
|
115
160
|
// workspace 和本地框架链接均使用消费应用的 React 与状态管理实例。
|
|
116
161
|
dedupe: ["react", "react-dom", "react-redux", "@reduxjs/toolkit"].filter(
|
|
117
|
-
(name) => (0,
|
|
162
|
+
(name) => (0, import_node_fs2.existsSync)(import_node_path2.default.join(projectRoot, "node_modules", name))
|
|
118
163
|
)
|
|
119
164
|
},
|
|
120
165
|
ssr: {
|