Skip to content

Commit 10ed1ec

Browse files
committed
build(react): output bundle to its own dist/ instead of SignallingWebServer/www/ (#874)
Both reference frontend implementations were writing to SignallingWebServer/www/ with `clean: true`, so a top-level `npm run build --ws` ran the TS impl first and then had its output wiped by the React impl that ran second. Wilbur was then served the React impl's minimal page (auto-connect, no UI overlay) instead of the TS reference frontend. Point the React webpack at a local dist/ directory so the two implementations no longer collide. WEBPACK_OUTPUT_PATH is honoured for symmetry with the TS impl, and the readme documents how to have Wilbur serve this bundle via --http_root. (cherry picked from commit 1096245)
1 parent e120706 commit 10ed1ec

2 files changed

Lines changed: 20 additions & 2 deletions

File tree

Frontend/implementations/react/readme.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,16 @@ To build and run the React application, run:
1515
- `npm install`
1616
- `npm run build-all`
1717
- `npm run serve`
18+
19+
### Serving via Wilbur
20+
21+
Webpack outputs this bundle to `Frontend/implementations/react/dist/` (rather than `SignallingWebServer/www/`, which is reserved for the TypeScript reference frontend). To have Wilbur serve the React bundle, pass its path via `--http_root`:
22+
23+
```bash
24+
# Build the React bundle, then start Wilbur pointed at it
25+
npm run build --workspace Frontend/implementations/react
26+
./SignallingWebServer/platform_scripts/bash/start.sh \
27+
--http_root="$(pwd)/Frontend/implementations/react/dist"
28+
```
29+
30+
If you want webpack to write somewhere else (for example, to drop the bundle directly into a deploy directory), set `WEBPACK_OUTPUT_PATH` before running the build.

Frontend/implementations/react/webpack.common.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,12 @@ module.exports = {
5959
filename: '[name].js',
6060
library: 'epicgames-react-frontend',
6161
libraryTarget: 'umd',
62-
path: path.resolve(__dirname, '../../../SignallingWebServer/www'),
62+
// Output to a local dist/ rather than SignallingWebServer/www so this build
63+
// doesn't clobber the TypeScript reference frontend that Wilbur serves by default.
64+
// To have Wilbur serve this bundle, point it at dist/ via --http_root.
65+
path: process.env.WEBPACK_OUTPUT_PATH
66+
? path.resolve(process.env.WEBPACK_OUTPUT_PATH)
67+
: path.resolve(__dirname, './dist'),
6368
clean: true,
6469
globalObject: 'this',
6570
hashFunction: 'xxhash64',
@@ -69,7 +74,7 @@ module.exports = {
6974
},
7075
devServer: {
7176
static: {
72-
directory: path.join(__dirname, '../../../SignallingWebServer/www'),
77+
directory: path.join(__dirname, './dist'),
7378
},
7479
},
7580
}

0 commit comments

Comments
 (0)