File tree Expand file tree Collapse file tree 3 files changed +16
-11
lines changed Expand file tree Collapse file tree 3 files changed +16
-11
lines changed Original file line number Diff line number Diff line change 5
5
"module" : " index.ts" ,
6
6
"type" : " module" ,
7
7
"scripts" : {
8
- "dev" : " rm -rf build && bun run index.ts --watch --hot"
8
+ "dev" : " rm -rf build && bun run scripts/ index.ts --watch --hot"
9
9
},
10
10
"keywords" : [
11
11
" bun.sh" ,
Original file line number Diff line number Diff line change 1
1
import { watch } from "fs" ;
2
2
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
+ } ) {
4
10
let build = 0 ;
5
11
6
12
async function runBuild ( ) {
@@ -11,10 +17,14 @@ export function startBuilder(BUILD_DIR: string) {
11
17
splitting : true ,
12
18
publicPath : "./" ,
13
19
} ) ;
20
+
21
+ console . log (
22
+ "React App is running on port " + `${ process . env . HOST_URL } :` + PORT
23
+ ) ;
14
24
}
15
25
16
26
const srcWatcher = watch (
17
- `${ import . meta . dir } /src` ,
27
+ `. /src` ,
18
28
{ recursive : true } ,
19
29
async ( event , filename ) => {
20
30
await runBuild ( ) ;
Original file line number Diff line number Diff line change @@ -2,14 +2,13 @@ import path from "path";
2
2
import { statSync } from "fs" ;
3
3
import { startBuilder } from "./builder" ;
4
4
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" ;
8
7
9
8
const PORT = process . env . PORT || 3000 ;
10
9
11
10
// start build
12
- startBuilder ( BUILD_DIR ) ;
11
+ startBuilder ( { BUILD_DIR , PORT } ) ;
13
12
14
13
function serveFromDir ( config : {
15
14
directory : string ;
@@ -63,7 +62,3 @@ Bun.serve({
63
62
} ) ;
64
63
} ,
65
64
} ) ;
66
-
67
- console . log (
68
- "React App is running on port " + `${ process . env . HOST_URL } :` + PORT
69
- ) ;
You can’t perform that action at this time.
0 commit comments