Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

start tsx watch as child process #133

Merged
merged 2 commits into from
Jun 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
"build": "run-s build:*",
"build:remix": "remix build",
"build:server": "tsx ./other/build-server.ts",
"dev": "remix dev -c \"npm run dev:server\" --no-restart",
"dev:server": "cross-env MOCKS=true tsx watch --clear-screen=false --ignore \"app/**\" --ignore \"build/**\" --ignore \"node_modules/**\" --inspect ./index.js",
"dev": "remix dev -c \"cross-env MOCKS=true node --inspect ./server/dev-server.js\" --no-restart",
onemen marked this conversation as resolved.
Show resolved Hide resolved
"prisma:studio": "prisma studio",
"format": "prettier --write .",
"lint": "eslint --cache --cache-location ./node_modules/.cache/eslint .",
Expand Down
17 changes: 17 additions & 0 deletions server/dev-server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { execa } from 'execa'

if (process.env.NODE_ENV === 'production') {
await import('./index.js')
} else {
const command =
'tsx watch --clear-screen=false --ignore "app/**" --ignore "build/**" --ignore "node_modules/**" ./index.js'
execa(command, {
stdio: ['ignore', 'inherit', 'inherit'],
env: {
...process.env,
FORCE_COLOR: true,
},
// https://github.com/sindresorhus/execa/issues/433
windowsHide: false,
})
}