BoxLang 🚀 A New JVM Dynamic Language Learn More...

BrowserSync

v1.3.3 CommandBox Modules

BrowserSync for CommandBox

BrowserSync will automatically refresh your browser window whenever you save files, allowing for fast, efficient development.

Installation:

Install browsersync using commandbox:

install commandbox-browsersync

This tool requires nodejs, (unfortunately). Once you install that, cd to your site root and:

browsersync [ proxyPort = random ] [ fwreinit = true ]

browsersync 4500 false (proxy port will be 4500, no fwreinit)

proxyPort ( default: random ) and fwreinit ( default: true ) are both optional.

If the npm dependencies don't exist we'll attempt to install them for you.

Caviat Emptor

  • The npm installs will likely fail if your site is in a dropbox folder or has anything else running that may lock files. If npm fails, shut down any program that is using the site folder while the installs are going on. This part of the process only happens once.
  • If you're on Windows, you should also not run the npm installs "as administrator" unless you're logged in as administrator. The global packages are saved under a user account and will not be available unless you're running everything under that account.
  • If you want us to reinit the framework automatically on core file changes (models, handlers, config, interceptors) you must have a "/healthcheck" route or handler set up. This route is set up by default in /config/router.cfc when using coldbox create app.
/config/router.cfc
=============

route("/healthcheck",function(event,rc,prc){
    return "Ok!"; 
});

The tool can launch your commandbox server if it's not already running and will create a nodejs browsersync proxy at your commandbox server port + 1, if that port is available, or another random port if not. Any changes to files in your layouts, views, handlers or models folders will cause the browser to reload.

Browsersync also has a UI that lets you configure its behavior, including the ability to throttle bandwidth so you can simulate slow links (from mobile devices, for example) You should be able to reach it at http://localhost:3001

commandbox-browsersync change

1.3.3

  • fixed hang on no healthcheck route bug

1.3.2

  • fixed watch folders/framework reinit bug

1.3.0

  • changed to using random proxy ports instead of forcing 3000

1.2.0

  • added fwreinit for core files

1.1.0

  • no longer overwriting package.json if it exists.

$ box install commandbox-browsersync

No collaborators yet.
   
  • {{ getFullDate("2020-04-21T19:51:28Z") }}
  • {{ getFullDate("2020-04-26T10:09:24Z") }}
  • 3,769
  • 355