@softnetics/dev-server
v0.0.2
Published
Run a node app in "dev mode"
Downloads
24
Keywords
Readme
dev-server
A simple utility to run a node app in "dev mode"
Features
- Load
.envfiles and restart on their changes - Manually restart by pressing
r
Usage
// dev.js
import { createDevServer } from '@softnetics/dev-server'
import chokidar from 'chokidar'
const { start, stop, restart } = createDevServer({
command: 'node src/server.js',
})
start()
// watch for changes in src
chokidar.watch('./src').on('all', () => restart())Then run the dev server
node dev.jsWith tsup
In a project that requires a bundling process, you can use tsup watch mode to automatically rebuild the project on source change, and start the dev server on successful build.
When a source file is changed, the dev server will automatically stop before tsup restarts the build process.
// dev.js
import { tsupDevServer } from '@softnetics/dev-server'
import { build } from 'tsup'
build({
entry: ['src/server.ts'],
watch: true,
onSuccess: tsupDevServer({
command: 'node dist/server.js',
}),
})