# @zhourengui/esbuild-dev-server

> ⚡️ Fast, lightweight and powerful development server for esbuild

Latest version **1.0.16** (published 2023-02-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @zhourengui/esbuild-dev-server
pnpm add @zhourengui/esbuild-dev-server
yarn add @zhourengui/esbuild-dev-server
bun add @zhourengui/esbuild-dev-server
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.16 |
| Published | 2023-02-24 |
| First published | 2023-02-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 7.7 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Maintainers | zhourengui |
| Keywords | esbuild, http-proxy, proxy, dev-server |

## Links

- npm: https://www.npmjs.com/package/@zhourengui/esbuild-dev-server
- Repository: https://github.com/zhourengui/esbuild-dev-server
- Homepage: https://github.com/zhourengui
- Issues: https://github.com/zhourengui/esbuild-dev-server/issues
- npm.io page: https://npm.io/package/@zhourengui/esbuild-dev-server

## Dependencies (6)

- [cors](https://npm.io/package/cors.md) ^2.8.5
- [open](https://npm.io/package/open.md) ^8.4.1
- [chalk](https://npm.io/package/chalk.md) ^4.1.2
- [connect](https://npm.io/package/connect.md) ^3.7.0
- [esbuild](https://npm.io/package/esbuild.md) ^0.17.8
- [connect-history-api-fallback](https://npm.io/package/connect-history-api-fallback.md) ^2.0.0

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.0.16 (latest) — 2023-02-24
- 1.0.15 — 2023-02-20
- 1.0.14 — 2023-02-20
- 1.0.13 — 2023-02-19
- 1.0.12 — 2023-02-19
- 1.0.11 — 2023-02-18
- 1.0.10 — 2023-02-18
- 1.0.9 — 2023-02-18
- 1.0.8 — 2023-02-18
- 1.0.7 — 2023-02-17
- 1.0.6 — 2023-02-17
- 1.0.5 — 2023-02-16
- 1.0.4 — 2023-02-16
- 1.0.3 — 2023-02-15
- 1.0.2 — 2023-02-15
- … 2 more at https://npm.io/package/@zhourengui/esbuild-dev-server/versions

## README

# esbuild-dev-server

<g-emoji class="g-emoji" alias="zap" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/26a1.png">⚡️</g-emoji> Fast, lightweight and powerful development server for esbuild <g-emoji class="g-emoji" alias="zap" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/26a1.png">⚡️</g-emoji>

- Zero dependencies besides esbuild
- API proxy support
- Live reload
- SPA support through History API fallback
- Fully typed with TypeScript

## Installation

```bash
npm install @zhourengui/esbuild-dev-server
# or
yarn add @zhourengui/esbuild-dev-server
```

## Usage

```mjs
import { createDevServer } from '@zhourengui/esbuild-dev-server';

createDevServer(esbuildOptions, {
  servedir: 'dist/web',
  port: 8080,
  proxy: {
    '^/api/v1': {
      target: 'https://www.google.com/',
      changeOrigin: true,
    },
  },
});
```

See [example](https://github.com/zhourengui/esbuild-dev-server/tree/master/example) folder for examples.

## API

createDevServer(esbuildOptions, serverOptions)

#### esbuildOptions

Options passed to [esbuild Build API](https://esbuild.github.io/api/).

#### serverOptions

| Option   | Description                                            | Required | Default |
| -------- | ------------------------------------------------------ | -------- | ------- |
| servedir | build directory                                        | True     | None    |
| port     | Port number to listen for requests on.                 | True     | None    |
| open     | Open in the default browser after starting the service | False    | False   |
| proxy    | proxy http network request                             | False    | None    |

## Proxying

```json
{
  "proxy": {
    "^/api/v1": {
      "target": "https://www.google.com.hk/",
      "pathRewrite": {
        "^/api/v1": "replace string"
      },
      "changeOrigin": true
    }
  }
}
```

Matching prefixes support regular expressions.

## Hot Reloading

Add the following code to the entry file:

```js
// Hot Module
if (process.env.NODE_ENV === 'development') {
  import('@zhourengui/esbuild-dev-server/lib/hot-reloading');
}
```

## Todo List

- [ ] Add Tests

---
_Source: https://npm.io/package/@zhourengui/esbuild-dev-server · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
