Skip to content

Commit

Permalink
chore(console): improve app dx (#3581)
Browse files Browse the repository at this point in the history
Enables hot reloading for the console app and the console server.
  • Loading branch information
skyrpex committed Jul 24, 2023
1 parent 96b9e0c commit c132000
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
9 changes: 9 additions & 0 deletions apps/wing-console/console/app/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Contributing to Wing Console

## Start dev mode

```sh
pnpm dev
```

Also, you have to start the dev script on the `apps/wing-console/console/server` package.
2 changes: 1 addition & 1 deletion apps/wing-console/console/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"scripts": {
"preview": "node scripts/preview.mjs",
"dev": "node scripts/dev.mjs",
"dev": "tsx watch scripts/dev.mjs",
"compile": "tsup",
"eslint": "eslint --ext .js,.cjs,.ts,.cts,.mts,.tsx --no-error-on-unmatched-pattern . --fix",
"test": "playwright test --update-snapshots",
Expand Down
26 changes: 15 additions & 11 deletions apps/wing-console/console/app/scripts/dev.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,11 @@ const options = parseArgs({
},
});

const vite = await createViteServer({
...viteConfig,
server: { middlewareMode: true },
});

const { port } = await createConsoleServer({
const consoleServer = await createConsoleServer({
wingfile:
options.values.wingfile ??
fileURLToPath(new URL("../demo/index.w", import.meta.url)),
requestedPort: 1214,
async onExpressCreated(app) {
app.use(vite.middlewares);
},
log: {
info: console.log,
error: console.error,
Expand All @@ -49,6 +41,18 @@ const { port } = await createConsoleServer({
requireAcceptTerms: true,
});

await open(`http://localhost:${port}`);
const vite = await createViteServer({
...viteConfig,
server: {
proxy: {
"/trpc": {
target: `http://localhost:${consoleServer.port}`,
changeOrigin: true,
ws: true,
},
},
open: true,
},
});

console.log(`Wing Console is running on http://localhost:${port}/`);
await vite.listen();
7 changes: 7 additions & 0 deletions apps/wing-console/console/server/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Contributing to `@wingconsole/server`

## Start dev mode

```sh
pnpm dev
```

0 comments on commit c132000

Please sign in to comment.