Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore live-reloading. Fix 404 bounce handler! #397

Merged
merged 1 commit into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions config/common.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {cleanPlugin} from 'esbuild-clean-plugin'
import copyStaticFiles from 'esbuild-copy-static-files'
import progress from 'esbuild-plugin-progress'
import svgrPlugin from 'esbuild-plugin-svgr'
Expand Down Expand Up @@ -38,7 +37,6 @@ export const build = {
logLevel: 'info',
plugins: [
progress(),
cleanPlugin(),
svgrPlugin(),
copyStaticFiles({
src: assetsDir,
Expand Down
19 changes: 15 additions & 4 deletions config/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,21 @@ const proxyRequestHandler = ((options, res) => http.request(options, (proxyRes)
)


/**
* "It's not possible to hook into esbuild's local server to customize
* the behavior of the server itself. Instead, behavior should be
* customized by putting a proxy in front of esbuild."
*
* We intend to serve on the SERVE_PORT defined above, so run esbuild
* on the port below it, and use the SERVE_PORT for a proxy. The
* proxy handles 404s with the bounce script above.
*
* See https://esbuild.github.io/api/#customizing-server-behavior
*/
esbuild.serve({
port: SERVE_PORT,
port: SERVE_PORT - 1,
servedir: common.build.outdir,
}, {}).then((result) => {
}, common.build).then((result) => {
// The result tells us where esbuild's local server is
const {host, port} = result

Expand All @@ -70,8 +81,8 @@ esbuild.serve({

// Forward the body of the request to esbuild
req.pipe(proxyReq, {end: true})
}).listen()
console.log(`serving on http://localhost:${port} and watching...`)
}).listen(SERVE_PORT)
console.log(`serving on http://localhost:${SERVE_PORT} and watching...`)
}).catch((error) => {
console.error(`could not start serving: `, error)
process.exit(1)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bldrs",
"version": "1.0.0-r403",
"version": "1.0.0-r433",
"main": "src/index.jsx",
"homepage": "https://github.com/bldrs-ai/Share",
"bugs": {
Expand Down