vb-serve

Serves static application assets on a local web server started during the Grunt build process (vb-process-local and vb-deploy tasks). The served static assets root is either in the build/processed directory for a processed (non-optimized) application or in the build/optimized directory for an optimized application.

Note:

Application assets produced by vb-process-local are environment agnostic and contain several unresolved environment references, which are resolved when application assets are deployed to a Visual Builder runtime instance by vb-deploy. See Setup to Resolve Environment Variables for details.

The following table describes the subtasks, hooks, and inputs and outputs of the vb-serve task:

Detail Description
subtasks n/a
multitask no
hooks n/a
input build/[processed | optimized]/*
output n/a

The following table describes the task target of the vb-serve task:

Detail Mandatory Description
application_path yes Path to the served web application (for example, webApps/myApp). .

The following table describes the options for the vb-deploy task:

Name Mandatory Default Value Description
application no First web application found Path to the application to be served. Similar to passing the application path via task target, for example, webApps/myApp.
boundPortFile yes n/a Path to the file where vb-serve writes the bound port number. This is useful if you don't specify the port and a free system port is used, but you need an automated system to connect to the served application.
open no false If true, a new browser window will be opened for the served URL.
port no 0 (binds to a free port) Server port
The options can be set either as command-line options or via the Grunt configuration object. Here's an example from the command line:
# First build the application sources
./node_modules/.bin/grunt vb-process-local
# serve the assets at port 8888 and open the application URL in browser
./node_modules/.bin/grunt vb-serve:webApps/myApp --port=8888 --open

The vb-serve task does not finish until you stop it explicitly. You can also stop the task (and the server) by sending a GET request to http://localhost:<port>/stop.