Skip to content

Commit c9d1f8a

Browse files
committed
0.4.2
1 parent fcea0bf commit c9d1f8a

3 files changed

Lines changed: 129 additions & 11 deletions

File tree

cli.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import path from "path";
55
import fs from "fs";
66
import { fileURLToPath } from "url";
77
import { select } from "@inquirer/prompts";
8+
import sirv from "sirv";
9+
import { createServer } from "http";
810

911
let open;
1012

@@ -118,20 +120,24 @@ function startRestApi(profile) {
118120
}
119121

120122
function startFrontend() {
121-
console.log("Starting frontend (Vite preview)...");
123+
console.log("Starting frontend...");
122124

123-
const viteBin = path.join(__dirname, "node_modules", ".bin", "vite");
125+
const distPath = path.join(__dirname, "dist", "app");
124126

125-
const proc = spawn(viteBin, ["preview", "--port", FRONTEND_PORT], {
126-
cwd: __dirname,
127-
stdio: "ignore",
127+
const serve = sirv(distPath, {
128+
single: true,
129+
gzip: true,
128130
});
129131

130-
proc.on("exit", (code) => {
131-
console.log(`\nFrontend exited with code ${code}`);
132+
const server = createServer((req, res) => {
133+
serve(req, res);
132134
});
133135

134-
return proc;
136+
server.listen(4173, () => {
137+
console.log("Frontend ready: http://localhost:4173");
138+
});
139+
140+
return server;
135141
}
136142

137143
/* ---------------------------

0 commit comments

Comments
 (0)