Skip to content

Commit 08b6b8a

Browse files
committed
moved scripts to scripts folder and updated script in package.json
1 parent f7cf785 commit 08b6b8a

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"module": "index.ts",
66
"type": "module",
77
"scripts": {
8-
"dev": "rm -rf build && bun run index.ts --watch --hot"
8+
"dev": "rm -rf build && bun run scripts/index.ts --watch --hot"
99
},
1010
"keywords": [
1111
"bun.sh",

builder.ts renamed to scripts/builder.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
import { watch } from "fs";
22

3-
export function startBuilder(BUILD_DIR: string) {
3+
export function startBuilder({
4+
BUILD_DIR,
5+
PORT,
6+
}: {
7+
BUILD_DIR: string;
8+
PORT: string | number;
9+
}) {
410
let build = 0;
511

612
async function runBuild() {
@@ -11,10 +17,14 @@ export function startBuilder(BUILD_DIR: string) {
1117
splitting: true,
1218
publicPath: "./",
1319
});
20+
21+
console.log(
22+
"React App is running on port " + `${process.env.HOST_URL}:` + PORT
23+
);
1424
}
1525

1626
const srcWatcher = watch(
17-
`${import.meta.dir}/src`,
27+
`./src`,
1828
{ recursive: true },
1929
async (event, filename) => {
2030
await runBuild();

index.ts renamed to scripts/index.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ import path from "path";
22
import { statSync } from "fs";
33
import { startBuilder } from "./builder";
44

5-
const PROJECT_ROOT = import.meta.dir;
6-
const PUBLIC_DIR = path.resolve(PROJECT_ROOT, "public");
7-
const BUILD_DIR = path.resolve(PROJECT_ROOT, "build");
5+
const PUBLIC_DIR = "./public";
6+
const BUILD_DIR = "./build";
87

98
const PORT = process.env.PORT || 3000;
109

1110
// start build
12-
startBuilder(BUILD_DIR);
11+
startBuilder({ BUILD_DIR, PORT });
1312

1413
function serveFromDir(config: {
1514
directory: string;
@@ -63,7 +62,3 @@ Bun.serve({
6362
});
6463
},
6564
});
66-
67-
console.log(
68-
"React App is running on port " + `${process.env.HOST_URL}:` + PORT
69-
);

0 commit comments

Comments
 (0)