Skip to content

Commit d66318f

Browse files
CoveMBericglau
andauthored
Port server option (#467)
Co-authored-by: Eric Lau <[email protected]>
1 parent 03caa4c commit d66318f

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Install dependencies with `yarn install`.
1818
- Run `yarn lint` to run the linter across the codebase (optionally `yarn lint --fix` will automatically fix fixable issues, like formatting issues).
1919

2020
`packages/ui` is the interface built in Svelte. From the `packages/ui` directory, run `yarn dev` to spin up a local server to develop the UI.
21+
- By default, the local server runs on port 8080. To use another port, set the environment variable `PORT`, for example: `PORT=800 yarn dev`
2122

2223
You'll need to supply your own environment variables if you want to enable Wizard AI Assistant (OPENAI_API_KEY) and/or logging (REDIS_URL, REDIS_TOKEN).
2324

packages/ui/rollup.config.mjs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import svelte from 'rollup-plugin-svelte';
1+
import alias from '@rollup/plugin-alias';
22
import commonjs from '@rollup/plugin-commonjs';
33
import json from '@rollup/plugin-json';
44
import resolve from '@rollup/plugin-node-resolve';
55
import replace from '@rollup/plugin-replace';
6-
import alias from '@rollup/plugin-alias';
7-
import livereload from 'rollup-plugin-livereload';
8-
import { terser } from 'rollup-plugin-terser';
96
import typescript from '@rollup/plugin-typescript';
10-
import styles from 'rollup-plugin-styles';
117
import proc from 'child_process';
128
import events from 'events';
9+
import livereload from 'rollup-plugin-livereload';
10+
import styles from 'rollup-plugin-styles';
11+
import svelte from 'rollup-plugin-svelte';
12+
import { terser } from 'rollup-plugin-terser';
1313
import serve from './rollup.server.mjs';
1414

1515
const production = !process.env.ROLLUP_WATCH;
@@ -142,7 +142,10 @@ export default [
142142

143143
// In dev mode, call `npm run start` once
144144
// the bundle has been generated
145-
!production && serve(),
145+
!production &&
146+
serve({
147+
port: process.env.PORT || '8080',
148+
}),
146149

147150
livereloader,
148151

packages/ui/rollup.server.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ const state = (global.ROLLUP_SERVER = global.ROLLUP_SERVER || {
44
server: undefined,
55
});
66

7-
export default function serve() {
7+
export default function serve({ port = '8080' }) {
88
function toExit() {
99
if (state.server) state.server.kill(0);
1010
}
1111

1212
return {
1313
writeBundle() {
1414
if (state.server) return;
15-
state.server = proc.spawn('npm', ['run', 'start', '--', '--dev'], {
15+
state.server = proc.spawn('npm', ['run', 'start', '--', '--dev', '-p', port], {
1616
stdio: ['ignore', 'inherit', 'inherit'],
1717
shell: true,
1818
});

0 commit comments

Comments
 (0)