fix: bundle UI dist into server package for npm publishing
The server's static-ui mode resolves the UI dist path relative to its own directory. In the monorepo it finds ../../ui/dist, but when published to npm the UI package isn't available. - server/src/app.ts: try ../ui-dist (published) then ../../ui/dist (dev), gracefully degrade to API-only if neither exists - server/package.json: include ui-dist/ in published files - scripts/release.sh: build UI and copy dist to server/ui-dist before publishing, clean up in restore step Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -17,7 +17,8 @@
|
||||
"types": "./dist/index.d.ts"
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
"dist",
|
||||
"ui-dist"
|
||||
],
|
||||
"scripts": {
|
||||
"dev": "tsx src/index.ts",
|
||||
|
||||
@@ -124,12 +124,20 @@ export async function createApp(
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
if (opts.uiMode === "static") {
|
||||
// Serve built UI from ui/dist in production.
|
||||
const uiDist = path.resolve(__dirname, "../../ui/dist");
|
||||
app.use(express.static(uiDist));
|
||||
app.get(/.*/, (_req, res) => {
|
||||
res.sendFile(path.join(uiDist, "index.html"));
|
||||
});
|
||||
// Try published location first (server/ui-dist/), then monorepo dev location (../../ui/dist)
|
||||
const candidates = [
|
||||
path.resolve(__dirname, "../ui-dist"),
|
||||
path.resolve(__dirname, "../../ui/dist"),
|
||||
];
|
||||
const uiDist = candidates.find((p) => fs.existsSync(path.join(p, "index.html")));
|
||||
if (uiDist) {
|
||||
app.use(express.static(uiDist));
|
||||
app.get(/.*/, (_req, res) => {
|
||||
res.sendFile(path.join(uiDist, "index.html"));
|
||||
});
|
||||
} else {
|
||||
console.warn("[paperclip] UI dist not found; running in API-only mode");
|
||||
}
|
||||
}
|
||||
|
||||
if (opts.uiMode === "vite-dev") {
|
||||
|
||||
Reference in New Issue
Block a user