{"id":28705040,"url":"https://github.com/oblador/esbuild-server","last_synced_at":"2025-06-14T14:09:29.873Z","repository":{"id":37446419,"uuid":"472052667","full_name":"oblador/esbuild-server","owner":"oblador","description":"Fast, lightweight and powerful development server for esbuild","archived":false,"fork":false,"pushed_at":"2023-09-05T07:34:48.000Z","size":26,"stargazers_count":39,"open_issues_count":4,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-09T04:51:58.323Z","etag":null,"topics":["esbuild","esbuild-dev-server"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oblador.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-03-20T17:28:45.000Z","updated_at":"2025-05-17T18:04:37.000Z","dependencies_parsed_at":"2024-06-19T00:11:31.734Z","dependency_job_id":"4f39d982-1884-4d44-8938-4b2025dc45b5","html_url":"https://github.com/oblador/esbuild-server","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/oblador/esbuild-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oblador%2Fesbuild-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oblador%2Fesbuild-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oblador%2Fesbuild-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oblador%2Fesbuild-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oblador","download_url":"https://codeload.github.com/oblador/esbuild-server/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oblador%2Fesbuild-server/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259827667,"owners_count":22917714,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["esbuild","esbuild-dev-server"],"created_at":"2025-06-14T14:09:28.965Z","updated_at":"2025-06-14T14:09:29.864Z","avatar_url":"https://github.com/oblador.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# esbuild-server\n\n**⚡️ Fast, lightweight and powerful development server for esbuild ⚡️**\n\n- Zero dependencies besides esbuild\n- API proxy support\n- Live reload\n- SPA support through History API fallback\n- Fully typed with TypeScript\n\n## Installation\n\n```bash\nnpm install --save-dev esbuild esbuild-server\n```\n\n## Usage\n\nCreate a new file for your dev server:\n\n```js\n// dev-server.js\nrequire('esbuild-server')\n  .createServer(\n    {\n      bundle: true,\n      entryPoints: ['src/app.js'],\n    },\n    {\n      static: 'public',\n    }\n  )\n  .start();\n```\n\nAssuming you have an `index.html` file in the `public` folder you can now run the server with `node dev-server.js`.\n\nSee `example` folder for examples.\n\n## API\n\n### createServer(esbuildOptions, serverOptions)\n\n#### `esbuildOptions`\n\nOptions passed to [esbuild Build API](https://esbuild.github.io/api/#build-api). If not specified `watch` defaults to `true` to enable continous build and live reload, and similarly if no type of output option is specified `outdir` is set to a temporary directory.\n\n#### `serverOptions`\n\n| Option                   | Description                                                                                                                                 | Default |\n|--------------------------|---------------------------------------------------------------------------------------------------------------------------------------------| ------- |\n| **`static`**             | Path to your static assets folder, should contain an `index.html` file.                                                                     | _None_  |\n| **`port`**               | Port number to listen for requests on.                                                                                                      | `8080`  |\n| **`historyApiFallback`** | For Single Page Apps using the HTML5 History API, the index.html page is served instead of 404 responses.                                   | `false` |\n| **`injectLiveReload`**   | Inject snippet to automatically reload the page when file changes are detected.                                                             | `true`  |\n| **`open`**               | Open the browser after server had been started. Set to a string to open a particular path.                                                  | `false` |\n| **`proxy`**              | Proxy certain paths to a separate API backend when you want to serve API requests on the same domain. Pass a function for dynamic rewrites. | `{}`    |\n| **`onProxyRewrite`**     | Callback function when a proxy rewrite happens, useful for logging or altering the response.                                                | _None_  |\n| **`http`**               | http options.                                                                                                                               | _None_  |\n| **`https`**              | https options.                                                                                                                              | _None_  |\n\n## Proxying\n\n### Static\n\n```js\n{\n  proxy: {\n    '/api': 'http://localhost:3000'\n  }\n}\n```\n\nA request to `/api/users` will now proxy the request to `http://localhost:3000/api/users`. If you want to rewrite the base use dynamic approach instead:\n\n### Dynamic\n\n```js\n{\n  proxy: (path) =\u003e {\n    if (path.startsWith('/api')) {\n      return path.replace(/^\\/api/, 'http://localhost:3000');\n    }\n  };\n}\n```\n\nA request to `/api/users` will now proxy the request to `http://localhost:3000/users`.\n\n### Modifying the response\n\n```js\n{\n  onProxyRewrite: (proxyRes, localUrl, proxyUrl) =\u003e {\n    console.log(`Proxying ${localUrl} to ${proxyUrl}`);\n    proxyRes.headers['x-my-custom-header'] = 'yep';\n    return proxyRes;\n  };\n}\n```\n\n## Https\n\n```js\n{\n  https: {\n    key: fs.readFileSync('server.key'),\n    cert: fs.readFileSync('server.crt'),\n  }\n}\n```\n\n## Live reload\n\nIf you want more control over where the live reload script is injected you can place it manually with:\n\n```html\n\u003cscript src=\"/esbuild-livereload.js\" async\u003e\u003c/script\u003e\n```\n\n## License\n\nMIT © Joel Arvidsson 2022 – present\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foblador%2Fesbuild-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foblador%2Fesbuild-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foblador%2Fesbuild-server/lists"}