Skip to content

Commit

Permalink
feat: auto host mount dev server when running in a codespace
Browse files Browse the repository at this point in the history
also clarify some documentation to consistently expect `pnpm` as a
package manager / task runner. `npm` _should_ work equivalently in
most cases, but being consistent might help prevent unexpected
surprises.
  • Loading branch information
jamesdabbs committed May 3, 2023
1 parent 4e24e63 commit 128738a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@ $ curl -s localhost:3141/refs/heads/master | jq '.version'
```bash
# in packages/viewer
# compile .js and .css assets
npm run build

# serve assets and expose them externally
npm run start -- --host
pnpm run dev
```

## Troubleshooting
Expand Down
6 changes: 5 additions & 1 deletion packages/viewer/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import copy from 'rollup-plugin-copy';
import { spawn } from 'node:child_process';

const production = !process.env.ROLLUP_WATCH;
const codespace = process.env.CODESPACES === 'true';

function serve() {
let server;
Expand All @@ -24,7 +25,10 @@ function serve() {
return {
writeBundle() {
if (server) return;
server = spawn('npm', ['run', 'start', '--', '--dev'], {
const args = ['run', 'start', '--', '--dev'];
if (codespace) { args.push('--host') }

server = spawn('pnpm', args, {
stdio: ['ignore', 'inherit', 'inherit'],
shell: true
});
Expand Down

0 comments on commit 128738a

Please sign in to comment.