Skip to content

Commit 1ffd187

Browse files
fix: Fix frontend build when using VSCode debugger
This was slightly broken after we moved to turbo, but now that we've changed how tailwind works it's 100% broken, we can fix it by: - using the same bin/start-frontend script - add a new `SKIP_TYPEGEN` script for those (like me) who wanna skip typegen - This is a requirement for VSCode debug mode because typegen crashes because it doesn't pass Typescript checks sadly
1 parent 0a250f5 commit 1ffd187

File tree

4 files changed

+29
-17
lines changed

4 files changed

+29
-17
lines changed

.vscode/launch.json

+16-16
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"configurations": [
77
{
88
"name": "Frontend",
9-
"command": "bin/turbo --filter=@posthog/frontend start",
9+
"command": "bin/start-frontend",
1010
"request": "launch",
1111
"type": "node-terminal",
1212
"cwd": "${workspaceFolder}",
@@ -17,21 +17,24 @@
1717
},
1818
{
1919
"name": "Frontend (no typegen)",
20-
"command": "pnpm start-http",
20+
"command": "bin/start-frontend",
2121
"request": "launch",
2222
"type": "node-terminal",
23-
"cwd": "${workspaceFolder}/frontend",
23+
"cwd": "${workspaceFolder}",
2424
"presentation": {
2525
"group": "main"
2626
},
27-
"skipFiles": ["${workspaceFolder}/node_modules/kea-typegen/**/*.js"]
27+
"skipFiles": ["${workspaceFolder}/node_modules/kea-typegen/**/*.js"],
28+
"env": {
29+
"SKIP_TYPEGEN": "1"
30+
}
2831
},
2932
{
3033
"name": "Frontend (https)",
31-
"command": "bin/turbo --filter=@posthog/frontend start",
34+
"command": "bin/start-frontend",
3235
"request": "launch",
3336
"type": "node-terminal",
34-
"cwd": "${workspaceFolder}/frontend",
37+
"cwd": "${workspaceFolder}",
3538
"presentation": {
3639
"group": "main"
3740
},
@@ -276,7 +279,6 @@
276279
],
277280
"stopAll": true,
278281
"presentation": {
279-
"order": 1,
280282
"group": "compound"
281283
}
282284
},
@@ -292,37 +294,35 @@
292294
],
293295
"stopAll": true,
294296
"presentation": {
295-
"order": 1,
296297
"group": "compound"
297298
}
298299
},
299300
{
300-
"name": "PostHog (local billing)",
301+
"name": "PostHog (https)",
301302
"configurations": [
302-
"Backend (with local billing)",
303+
"Backend",
303304
"Celery Threaded Pool",
304-
"Frontend",
305+
"Celery Beat",
306+
"Frontend (https)",
305307
"Plugin Server",
306308
"Temporal Worker"
307309
],
308310
"stopAll": true,
309311
"presentation": {
310-
"order": 2,
311312
"group": "compound"
312313
}
313314
},
314315
{
315-
"name": "PostHog (https)",
316+
"name": "PostHog (local billing)",
316317
"configurations": [
317-
"Backend",
318+
"Backend (with local billing)",
318319
"Celery Threaded Pool",
319-
"Frontend (https)",
320+
"Frontend",
320321
"Plugin Server",
321322
"Temporal Worker"
322323
],
323324
"stopAll": true,
324325
"presentation": {
325-
"order": 2,
326326
"group": "compound"
327327
}
328328
}

bin/start-frontend

+7-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,10 @@ set -e
99
export DEBUG=0
1010

1111
pnpm --filter=@posthog/frontend... install
12-
bin/turbo --filter=@posthog/frontend start
12+
13+
# Choose between start and start-no-typegen based on SKIP_TYPEGEN env variable
14+
if [ "${SKIP_TYPEGEN}" = "1" ]; then
15+
bin/turbo --filter=@posthog/frontend start-no-typegen
16+
else
17+
bin/turbo --filter=@posthog/frontend start
18+
fi

frontend/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"build:tailwind": "pnpm --filter=@posthog/tailwind build",
2525
"watch:tailwind": "pnpm --filter=@posthog/tailwind start",
2626
"start": "concurrently -n ESBUILD,TYPEGEN,TAILWIND -c yellow,green,blue \"pnpm start-http\" \"pnpm run typegen:watch\" \"sleep 40 && pnpm watch:tailwind\"",
27+
"start-no-typegen": "concurrently -n ESBUILD,TAILWIND -c yellow,blue \"pnpm start-http\" \"sleep 40 && pnpm watch:tailwind\"",
2728
"start-http": "pnpm clean && pnpm copy-scripts && pnpm build:esbuild --dev",
2829
"start-docker": "pnpm start-http --host 0.0.0.0",
2930
"typegen:write": "cd .. && kea-typegen write --delete --show-ts-errors",

turbo.json

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
"persistent": true,
2424
"cache": false
2525
},
26+
"start-no-typegen": {
27+
"dependsOn": ["^build"],
28+
"persistent": true,
29+
"cache": false
30+
},
2631
"dev": {
2732
"dependsOn": ["^build"],
2833
"persistent": true,

0 commit comments

Comments
 (0)