⚡️ Fast, lightweight and powerful development server for esbuild ⚡️
- Zero dependencies besides esbuild
- API proxy support
- Live reload
- SPA support through History API fallback
- Fully typed with TypeScript
npm install @zhourengui/esbuild-dev-server
# or
yarn add @zhourengui/esbuild-dev-server
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 folder for examples.
createDevServer(esbuildOptions, serverOptions)
Options passed to esbuild Build API.
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 |
{
"proxy": {
"^/api/v1": {
"target": "https://www.google.com.hk/",
"pathRewrite": {
"^/api/v1": "replace string"
},
"changeOrigin": true
}
}
}
Matching prefixes support regular expressions.
Add the following code to the entry file:
// Hot Module
if (process.env.NODE_ENV === 'development') {
import('@zhourengui/esbuild-dev-server/lib/hot-reloading');
}
- Add Tests