Skip to content

Commit b3d1092

Browse files
committed
build(ui-scripts): allow to specify custom port for dev server
One can run now commands like "npm run dev -- -p 1234"
1 parent 2dabe86 commit b3d1092

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

docs/contributor-docs/dev-commands.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This is a quick developer reference for common Instructure UI repository command
1111
| Command | Description |
1212
| --------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1313
| `npm run bootstrap` | Clean all node modules and build output, reinstall dependencies, create fresh build including regenerating design tokens and type declaration files. |
14-
| `npm run dev` | Run a local instance of the documentation app in dev mode. Docs will be served at `http://0.0.0.0:9090` |
14+
| `npm run dev` | Run a local instance of the documentation app in dev mode. Docs will be served at `http://0.0.0.0:9090`. Port can be specified too e.g. `npm run dev -- -p 1234` |
1515
| `npm run start` | Run a local instance of the documentation app in production mode. The urls where the docs are being served will be included in the output of this command. |
1616
| `npm run build` | Run the build command for all Instructure UI packages. Similar to bootstrap, but without the cleaning steps, installation of dependencies, and without the token and type generation. |
1717
| `npm run build:watch` | Identical to `npm run build` but will watch for changes. Note: this command is rarely necessary to use. If you are running `npm run dev`, the docs app will already be watching for any changes for components. |

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
],
1616
"scripts": {
1717
"prestart": "npm run bootstrap",
18-
"start": "npm run start --workspace=docs-app",
19-
"start:watch": "npm run start:watch --workspace=docs-app",
20-
"dev": "npm run start:watch",
18+
"start": "npm run start --workspace=docs-app --",
19+
"start:watch": "npm run start:watch --workspace=docs-app --",
20+
"dev": "npm run start:watch --",
2121
"cy:component": "cypress run --component",
2222
"test:vitest": "vitest --watch=false",
2323
"test:vitest-watch": "vitest",
@@ -92,6 +92,7 @@
9292
"webpack": "^5.99.9"
9393
},
9494
"//dependency-comments": {
95+
"scripts": "The '--' at the end of commands is needed so user parameters are passed forward",
9596
"danger": "^11.3.1 -- add this back if we use it in pr-validation.yml",
9697
"chalk": "Chalk 5 is ESM. (used here by the scripts/ folder)",
9798
"tar": "Lerna 8 needs tar for this fixed(?) bug: https://github.com/lerna/lerna/issues/4005",

packages/__docs__/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"scripts": {
1414
"prestart": "npm run build:scripts:ts && node lib/build-docs.mjs",
1515
"start": "npm run prestart && ui-scripts bundle && ui-scripts server -p 8001",
16-
"start:watch": "npm run prestart && ui-scripts bundle --watch -p 9090",
17-
"start-watch-just-app": "ui-scripts bundle --watch -p 9090",
16+
"start:watch": "npm run prestart && ui-scripts bundle --watch",
17+
"start-watch-just-app": "ui-scripts bundle --watch",
1818
"bundle": "npm run prestart && ui-scripts bundle",
1919
"lint": "ui-scripts lint",
2020
"lint:fix": "ui-scripts lint --fix",

packages/ui-scripts/lib/build/webpack.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,12 @@ export default {
2828
command: 'bundle',
2929
desc: 'Build and optionally start an app with Webpack',
3030
builder: (yargs) => {
31-
yargs.option('port', { alias: 'p', desc: '' })
31+
yargs.option('port', { alias: 'p', desc: '', default: '9090' })
3232
yargs.option('watch', { boolean: true, desc: '' })
3333
yargs.strictOptions(true)
3434
},
3535
handler: async (argv) => {
3636
const { NODE_ENV, DEBUG, OMIT_INSTUI_DEPRECATION_WARNINGS } = process.env
37-
38-
let port = argv.port || '9090'
39-
4037
let command, webpackArgs
4138

4239
let envVars = {}
@@ -51,7 +48,7 @@ export default {
5148
NODE_ENV: 'development',
5249
DEBUG: '1'
5350
}
54-
webpackArgs = ['serve', '--mode=development', `--port=${port}`]
51+
webpackArgs = ['serve', '--mode=development', `--port=${argv.port}`]
5552
} else {
5653
command = 'webpack'
5754
envVars = {

0 commit comments

Comments
 (0)