Skip to content

Commit 5c7aeef

Browse files
feat: adding port customiztion and re-launch for watch
1 parent fbfc622 commit 5c7aeef

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,15 +335,19 @@ The following tasks are available:
335335
336336
- `gulp build` - Performs a build of all components and the top level package
337337
- `gulp buildComponents` - Performs a build of all components
338-
- `gulp dev` - Performs a lite build (custom properties only), opens your browser with the documentation site, then starts watching components and website files
338+
- `gulp dev` - Performs a lite build (custom properties only), runs browsersync and serves the documentation on the default port (3000), then starts watching components and website files
339339
- `gulp clean` - Cleans all output files for the project and all components
340-
- `gulp watch` - Assuming a build has already been performed, immediately opens your browser with the documentation site, then starts watching components and website files
340+
- `gulp watch` - Assuming a build has already been performed, re-starts starts watching components and website files. Presumes a browser is already open to your locally served docs
341+
- `gulp watch-relaunch` - Restarts watch and opens a new browser for the docs URL
341342
- `gulp buildCombined` - Builds the combined output files (`dist/spectrum-*.css`)
342343
- `gulp buildStandalone` - Builds the standalone output files (`dist/standalone/spectrum-*.css`)
343344
- `gulp release` - Performs a release of the top-level package
344345
- `gulp packageLint` - Lint the `package.json` file for each component in the monorepo
345346
- `gulp readmeLint` - Generate a generic `README.md` file for each component in the monorepo
346347
348+
Note: `yarn run dev` will run `gulp dev` above but trigger browsersync to open the documentation URL. You can set `BROWSERSYNC_OPEN=true` to change dev and watch to always open the URL.
349+
350+
You can set a new port for `watch` by setting `BROWSERSYNC_PORT=<port number>`, e.g. `export BROWSERSYNC_PORT=9000; gulp watch` to set the port to `9000`.
347351
348352
349353
## Testing

gulpfile.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,11 @@ exports.devHeavy = gulp.series(
215215
exports.devHeavy
216216
);
217217

218+
exports['watch-relaunch'] = function() {
219+
process.env['BROWSERSYNC_OPEN'] = true;
220+
exports.watch();
221+
}
222+
218223
exports.buildDocs = builder.buildDocs;
219224

220225
exports.releaseBundles = releaseBundles;

tools/bundle-builder/dev/index.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,26 @@ const gulp = require('gulp');
1414
const logger = require('gulplog');
1515
const browserSync = require('browser-sync');
1616
const path = require('path');
17-
const dirs = require('../lib/dirs')
17+
const dirs = require('../lib/dirs');
1818

1919
const docs = require('../docs');
2020
const subrunner = require('../subrunner');
2121

2222
function serve() {
23+
24+
let PORT = 3000;
25+
26+
if (process.env.BROWSERSYNC_PORT) {
27+
PORT = process.env.BROWSERSYNC_PORT;
28+
logger.info(`Setting '${PORT} as port for browsersync, which hopefully is valid`);
29+
}
30+
2331
browserSync({
2432
startPath: 'docs/index.html',
2533
server: `${process.cwd()}/dist/`,
2634
notify: process.env.BROWSERSYNC_NOTIFY === 'true' ? true : false,
27-
open: process.env.BROWSERSYNC_OPEN === 'true' ? true : false
35+
open: process.env.BROWSERSYNC_OPEN === 'true' ? true : false,
36+
port: PORT
2837
});
2938
}
3039

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,10 +1447,10 @@
14471447
resolved "https://registry.yarnpkg.com/@spectrum-css/radio/-/radio-3.0.24.tgz#7a08476edf42be2007b75f7765c18c26eb3a9880"
14481448
integrity sha512-C/saSKXb3dNCWprsP4iXkFFEmRrxwsdm2Al04myZ6pxOJ4tr1WjHAAtorwUgaUiyR87OnL1mGX2aWrFEN1mvtQ==
14491449

1450-
"@spectrum-css/spectrum-css-vr-test-assets-essential@^1.0.45":
1451-
version "1.0.45"
1452-
resolved "https://registry.yarnpkg.com/@spectrum-css/spectrum-css-vr-test-assets-essential/-/spectrum-css-vr-test-assets-essential-1.0.45.tgz#a850e194fb7cb3044d5a58b611728fcb174aab31"
1453-
integrity sha512-tJHCHTrR8De/SQfJGQ5qh8OYZd2t1pFj7xr5DPey+tDdYw3NAHDGO+MHMBZQfthsEs18jJIcNsxWr+Jg5dR5vQ==
1450+
"@spectrum-css/spectrum-css-vr-test-assets-essential@^1.0.46":
1451+
version "1.0.46"
1452+
resolved "https://registry.yarnpkg.com/@spectrum-css/spectrum-css-vr-test-assets-essential/-/spectrum-css-vr-test-assets-essential-1.0.46.tgz#8a8c9007003f5c7c1501b3a0ecb721f751f9f68b"
1453+
integrity sha512-09KcehdKIxpVTxmC3bkaCGiLwbxakFNZIirGQlwryu0qnuu1uzst+ELnZdh0s/O2akfmo43PRbaKiIL0x23NQg==
14541454

14551455
"@szmarczak/http-timer@^1.1.2":
14561456
version "1.1.2"

0 commit comments

Comments
 (0)