open-index/open-npm huggingface dataset:
npm package: @softnetics/dev-server
Description: Run a node app in "dev mode"
Author: suphon-t
Latest version: 0.0.2

# dev-server

A simple utility to run a node app in "dev mode"

## Features

- Load `.env` files and restart on their changes
- Manually restart by pressing `r`

## Usage

```javascript
// 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

```bash
node dev.js
```

### With [tsup](https://tsup.egoist.dev/)

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.

```javascript
// 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',
  }),
})
```