Fix build and watch (hopefully for good this time)

This commit is contained in:
Joseph Garrone 2024-05-20 21:07:59 +02:00
parent ccc5ac6a1f
commit 3c4bbf8aa7
3 changed files with 8 additions and 26 deletions

View File

@ -37,7 +37,6 @@
"author": "u/garronej",
"license": "MIT",
"files": [
"src/",
"dist/",
"!dist/tsconfig.tsbuildinfo",
"!dist/bin/",
@ -94,7 +93,6 @@
"@types/react": "^18.0.35",
"@types/react-dom": "^18.0.11",
"@types/yauzl": "^2.10.3",
"@types/yazl": "^2.4.5",
"@vercel/ncc": "^0.38.1",
"chalk": "^4.1.2",
"cheerio": "^1.0.0-rc.12",
@ -123,7 +121,6 @@
"vite": "^5.2.11",
"vitest": "^0.29.8",
"yauzl": "^2.10.0",
"yazl": "^2.5.1",
"zod": "^3.17.10"
}
}

View File

@ -107,6 +107,10 @@ fs.rmSync(join("dist", "ncc_out"), { recursive: true });
patchDeprecatedBufferApiUsage(join("dist", "vite-plugin", "index.js"));
fs.rmSync(join("dist", "src"), { recursive: true, force: true });
fs.cpSync("src", join("dist", "src"), { recursive: true });
console.log(chalk.green(`✓ built in ${((Date.now() - startTime) / 1000).toFixed(2)}s`));
function run(command: string) {

View File

@ -26,7 +26,6 @@ import { getThisCodebaseRootDirPath } from "../tools/getThisCodebaseRootDirPath"
import { Deferred } from "evt/tools/Deferred";
import { getAbsoluteAndInOsFormatPath } from "../tools/getAbsoluteAndInOsFormatPath";
import cliSelect from "cli-select";
import { isInside } from "../tools/isInside";
import * as runExclusive from "run-exclusive";
export type CliCommandOptions = CliCommandOptions_common & {
@ -404,8 +403,7 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
const dResult = new Deferred<{ isSuccess: boolean }>();
const child = child_process.spawn("npx", ["vite", "build"], {
cwd: buildOptions.reactAppRootDirPath,
env: process.env
cwd: buildOptions.reactAppRootDirPath
});
child.stdout.on("data", data => {
@ -461,30 +459,13 @@ export async function command(params: { cliCommandOptions: CliCommandOptions })
}
});
const { waitForDebounce } = waitForDebounceFactory({ delay: 400 });
const { waitForDebounce } = waitForDebounceFactory({ delay: 1_000 });
chokidar
.watch([srcDirPath, getThisCodebaseRootDirPath()], {
.watch([srcDirPath, pathJoin(getThisCodebaseRootDirPath(), "src")], {
ignoreInitial: true
})
.on("all", async (...[, filePath]) => {
for (const dir1 of ["src", "."]) {
for (const dir2 of ["bin", "vite-plugin"]) {
if (
isInside({
dirPath: pathJoin(
getThisCodebaseRootDirPath(),
dir1,
dir2
),
filePath
})
) {
return;
}
}
}
.on("all", async () => {
await waitForDebounce();
runBuildKeycloakTheme();