esbuild-server is a development server specifically designed to integrate with esbuild for rapid, lightweight asset bundling and serving. It features zero runtime dependencies beyond esbuild itself, providing live reload, API proxying with dynamic rewrite capabilities, SPA support via History API fallback, and static asset serving. The current stable version is `0.3.0`, with a release cadence that addresses bug fixes and introduces new features like HTTPS support. It differentiates itself by tightly coupling with esbuild's build process, offering a minimal setup, and being fully typed for TypeScript environments, making it an efficient choice for projects already leveraging esbuild.
npm install esbuild-serverVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up `esbuild-server` with TypeScript, bundling `src/app.ts` into a `dist` directory, serving static files from `public`, enabling live reload, history API fallback, and an example API proxy. It also shows how to define environment variables.
Upgrade `esbuild-server` to version `0.2.0` or higher to ensure compatibility with `esbuild 0.17+`. Ensure your `esbuild` peer dependency matches the recommended version range.
Ensure `server.key` and `server.crt` (or your chosen key/cert files) are present, correctly formatted, and readable by the Node.js process. They typically contain PEM-encoded data. Consult OpenSSL documentation for generating self-signed certificates for local development.
Install esbuild as a development dependency: `npm install --save-dev esbuild` or `yarn add -D esbuild`.
To prevent the browser from opening, set `open: false` in your `serverOptions`.
Run `npm install esbuild --save-dev` or `yarn add esbuild --dev`.
Change the `port` option in `serverOptions` to an available port, e.g., `{ port: 3000 }`.For CommonJS, use `const { createServer } = require('esbuild-server');`. For ESM, use `import { createServer } from 'esbuild-server';`.Verify that the paths to `key` and `cert` files are correct and that the Node.js process has read permissions for these files. Ensure the files actually exist at the specified location.