fix: improve server building on watch build

This commit is contained in:
Percs 2024-12-30 05:29:32 -06:00
parent 8d4b67e457
commit 58d1c013ab

View file

@ -4,6 +4,8 @@ import { createServer } from "http";
import Fastify from "fastify"; import Fastify from "fastify";
import fastifyStatic from "@fastify/static"; import fastifyStatic from "@fastify/static";
import { join } from "node:path"; import { join } from "node:path";
import rspackConfig from "./rspack.config.js";
import { rspack } from "@rspack/core";
import { spawn } from "node:child_process"; import { spawn } from "node:child_process";
import { fileURLToPath } from "node:url"; import { fileURLToPath } from "node:url";
import { server as wisp } from "@mercuryworkshop/wisp-js/server"; import { server as wisp } from "@mercuryworkshop/wisp-js/server";
@ -94,8 +96,14 @@ if (!process.env.CI) {
chmodSync(".git/hooks/pre-commit", 0o755); chmodSync(".git/hooks/pre-commit", 0o755);
} catch {} } catch {}
spawn("pnpm", ["rspack", "-w"], { const compiler = rspack(rspackConfig);
stdio: "inherit", compiler.watch({}, (err, stats) => {
cwd: process.cwd(), console.log(
stats.toString({
preset: "minimal",
colors: true,
version: false,
})
);
}); });
} }