Visual Builder Grunt Tasks

The build tasks exposed by the grunt-vb-build package have options and pre- and post- task hooks that you use when defining the task.

About Visual Builder Grunt Build Tasks

You use pre-defined Grunt tasks and options to define the tasks that are performed when building your application.

The public Grunt tasks that are used to build the application are exposed by the grunt-vb-build package. Some tasks have pre- and post- task hooks which you can use to add custom functionality.

Options that you specify for a task might be overridden by other options that have a higher priority. Task options have the following priority:

  1. Command line options
  2. Task:target specific options (for multitasks)
  3. Task specific options
  4. Generic "vb" options

vb-build

The main task that does a full application build, including deployment.

The following table describes the subtasks, hooks and inputs and outputs of the vb-build task.

Detail Description
subtasks vb-clean, vb-process, vb-optimize, vb-manifest, vb-stage
multitask n/a
hooks vb-pre-build, vb-post-build
input n/a
output build/to-be-processed.zip, build/processed/*, build/processed.zip, build/optimized/*, build/optimized.zip

This task does not define its own options. Any option of the subtasks is relevant.

vb-clean

This task cleans the build directory.

The following table describes the subtasks, hooks and inputs and outputs of the vb-clean task.

Detail Description
subtasks n/a
multitask n/a
hooks vb-pre-clean, vb-post-clean
input build/*
output n/a

The following table describes the options for the vb-clean task.

Name Mandatory Default Value Description
Build options
build no build Name of build directory.

vb-process

This task processes the local application sources by sending them to the Visual Builder instance.

The processing operation resolves various templates and further modifies (adds and updates) several application resources. The task makes a ZIP archive of the local application sources, sends the archive to the Visual Builder processing service and obtains an archive of processed sources. This archive is then expanded on the local filesystem and used for other tasks.

To run this task you must provide the Visual Builder URL and your credentials for accessing the Visual Builder instance. You can provide the credentials directly when you run the task. Alternatively, you can use the accessToken option to specify a valid OAuth access token.

The following table describes the subtasks, hooks and inputs and outputs of the vb-process task.

Detail Description
subtasks n/a
multitask n/a
hooks n/a
input ${gitSources}
output build/to-be-processed.zip, build/processed/*, build/processed.zip

The following table describes the options for the vb-process task.

Name Mandatory Default Value Description
Application selection options
id yes n/a ID of visual application you're going to build. The application needs to exist on the referred Visual Builder instance.
ver yes n/a Version of the visual application.
url yes n/a Your Visual Builder instance URL
Authentication options
username no n/a The username to be used to obtain OAuth access token for further communication with Visual Builder services.
password no n/a The password to be used to obtain OAuth access token for further communication with Visual Builder services.
accessToken no n/a The value of an OAuth access token. If provided, username and password options are necessary.
sslCertificate no n/a The path to the SSL certificate for the connection to Visual Builder instances provisioned with self-signed certificates.
Build options
build no build Name of build directory.
gitSources no ./ The location of the sources of the visual application.

vb-stage

This task stages (deploys) the visual application artifact to the Visual Builder instance.

The following table describes the subtasks, hooks and inputs and outputs of the vb-stage task.

Detail Description
subtasks n/a
multitask n/a
hooks vb-pre-stage, vb-post-stage
input build/optimized/*
output build/optimized.zip

The following table describes the options for the vb-stage task.

Name Mandatory Default Value Description
Application selection options
id yes n/a ID of visual application you're going to build. The application needs to exist on the referred VB instance.
ver yes n/a Version of the visual application.
url yes n/a Your Visual Builder instance URL
Authentication options
username no n/a The username to be used to obtain OAuth access token for further communication with Visual Builder services
password no n/a The password to be used to obtain OAuth access token for further communication with Visual Builder services.
accessToken no n/a The value of an OAuth access token. If provided, username and password options are necessary.
sslCertificate no n/a The path to the SSL certificate for the connection to Visual Builder instances provisioned with self-signed certificates.
Build options
build no build Name of build directory.
Data processing options
schema no new Specifies data schema processing during application stage or publish. The value can be new, dev, stage or live.

vb-publish

This task publishes a previously staged application to Live mode.

The following table describes the subtasks, hooks and inputs and outputs of the vb-publish task.

Detail Description
subtasks n/a
multitask n/a
hooks n/a
input n/a
output n/a

The following table describes the options for the vb-publish task.

Name Mandatory Default Value Description
Application selection options
id yes n/a ID of visual application you're going to build. The application needs to exist on the referred Visual Builder instance.
ver yes n/a Version of the visual application.
url yes n/a Your Visual Builder instance URL
Authentication options
username no n/a The username to be used to obtain OAuth access token for further communication with Visual Builder services.
password no n/a The password to be used to obtain OAuth access token for further communication with Visual Builder services.
accessToken no n/a The value of OAuth access token. If provided, username and password options are necessary.
sslCertificate no n/a The path to the SSL certificate for the connection to Visual Builder instances provisioned with self-signed certificates.
Data processing options
schema no new Specifies data schema processing during application stage or publish. The value can be new, dev, stage or live.

vb-optimize

This task optimizes the application sources by doing the following: minifies images and CSS, and creates minified requirejs module bundles.

The following table describes the subtasks, hooks and inputs and outputs of the vb-optimize task.

Detail Description
subtasks vb-prepare, vb-image-minify, vb-css-minify, vb-require-bundle
multitask n/a
hooks vb-pre-optimize, vb-post-optimize
input build/processed/*
output build/optimized/*

This task does not define its own options. Any option of the subtasks is relevant.

vb-prepare

This task copies either the raw application sources or the processed application sources to the build/optimized directory where the optimization takes place.

If the build/processed directory exists (as a result of the vb-process task) and no rawSourcesMode option is specified, this task will copy the build/processed directory into the build/optimized directory.

If the build/processed directory does NOT exist or rawSourcesMode option is set to "True", this task will copy the raw application sources (specified by the gitSources option, the default values of which is "./") into the build/optimized directory and invoke the vb-process-raw task.

The following table describes the subtasks, hooks and inputs and outputs of the vb-prepare task.

Detail Description
subtasks vb-process-raw
hooks n/a
input build/processed/* or ${gitSources}
output build/optimized/*

The following table describes the options for the vb-prepare task.

Name Mandatory Default Value Description
build no build Name of build directory.
rawSourcesMode no false Specifies if the task should copy raw application sources or metadata processed sources from the build/processed directory.

Note: The implicit value is defined by the existence of build/processed directory (true if the directory exist).

vb-require-bundle

This tasks creates minified requirejs module bundles.

The following table describes the subtasks, hooks and inputs and outputs of the vb-require-bundle task.

Detail Description
subtasks n/a
multitask config generator task: vb-require-bundle-configuration
hooks n/a
input build/optimized/*
output build/optimized/*

The following table describes the options for the vb-require-bundle task.

Name Mandatory Default Value Description
Build options
build no build Name of build directory.
Optimization options
emptyPaths no n/a Comma-separated list of require paths that are set "empty". Requirejs optimizer will not follow and bundle matching dependencies.
requirePaths no n/a

Requirejs optimizer paths mapping. This will override any default values or values read from app-flow.json

The value needs to be in a form of quoted JSON object: (--requirePaths='{ "foo": "boo" }')

bundles    

Defines custom require module bundles.

Configuration schema:

  • <bundle name>
    • modules
      • find
      • ids
    • exclude
      • find
      • ids
bundles.modules    

Specification of the modules that are supposed to be added to the enclosing bundle element.

Configuration schema:

  • find
  • ids
bundles.exclude    

Specify modules that shouldn't be part of the enclosing modules bundle. The exclusions are applied to all bundle modules, including modules added following transitive module dependencies.

Configuration schema:

  • find
  • ids
bundles.[exclude|modules].find    

List of regular expression patterns used for matching optimized application resources.

Regular expressions starting with exclamation mark are considered to be negative - resources matching these patterns won't be included.

bundles.[exclude|modules].ids     Specifies list of module ids.
transpile   false

Determines whether a separate set of require module bundles transpiled to ES5 code using babel preset-env preset should be created and stored into bundles/es5 directory.

When this option is set to true application's index.html is modified so it contains a code snippet that switches between the original bundles for modern browsers and the ES5 versions for IE11.

minify

  true When set to true babel minify preset is used to minify generated requirejs module bundles. The minification is also applied to the ES5 variants of the bundles if created.
include no n/a

Deprecated. You should use the bundles option instead.

Comma-separated list of regular expressions that specify what resources are supposed to be added to the optimization requirejs resources bundle.
exclude no n/a

Deprecated. You should use the bundles option instead.

Comma-separated list of regular expressions that specify what ought NOT to be added to the optimization requirejs resources bundle. A resource will not be added if it is both excluded and included.

vb-css-minify

This task minifies the CSS resources.

The following table describes the subtasks, hooks and inputs and outputs of the vb-css-minify task.

Detail Description
subtasks n/a
multitask config generator task: vb-css-minify-configuration
hooks n/a
input build/optimized/*
output build/optimized/*

The following table describes the options for the vb-css-minify task.

Name Mandatory Default Value Description
build no build Name of build directory.

vb-image-minify

This task minifies the image resources.

The following table describes the subtasks, hooks and inputs and outputs of the vb-image-minify task.

Detail Description
subtasks n/a
multitask config generator task: vb-image-minify-configuration
hooks n/a

The following table describes the options for the vb-image-minify task.

Name Mandatory Default Value Description
build no build Name of build directory.

vb-json-minify

This task minifies JSON resources to remove white spaces.

The following table describes the subtasks, hooks and inputs and outputs of the vb-json-minify task.

Detail Description
subtasks n/a
multitask config generator task: vb-json-minify-configuration
hooks n/a
input build/optimized/*
output build/optimized/*

vb-export

This task downloads application sources from the Visual Builder instance and expands the archive on the local filesystem for further processing.

The following table describes the subtasks, hooks and inputs and outputs of the vb-export task.

Detail Description
subtasks n/a
multitask n/a
hooks n/a
input build/optimized/*
output build/optimized/*

The following table describes the options for the vb-export task.

Name Mandatory Default Value Description
Application selection options
id yes n/a ID of the visual application you're going to build. The application needs to exist on the referred Visual Builder instance.
ver yes n/a Version of the visual application
url yes n/a URL of your Visual Builder instance
Authentication options
username no n/a The username to be used to obtain OAuth access token for further communication with Visual Builder services.
password no n/a The password to be used to obtain OAuth access token for further communication with Visual Builder services.
accessToken no n/a The value of an OAuth access token. If provided, username and password options are necessary.
sslCertificate no n/a The path to the SSL certificate for the connection to Visual Builder instances provisioned with self-signed certificates.
Build options
gitSources no ./ The location of the sources of the visual application.

vb-manifest

This task creates a build manifest that contains list of application resources, requirejs bundles mapping and the name of the version_<hash> directory.

The manifest location is build/optimized/webApps/<webAppName>/build-info.json

The following table describes the subtasks, hooks and inputs and outputs of the vb-manifest task.

Detail Description
subtasks n/a
multitask config generator task: vb-manifest-configuration
hooks n/a
input build/optimized/*
output build/optimized/*

The following table describes the options for the vb-manifest task.

Name Mandatory Default Value Description
build no build Name of build directory.

vb-process-raw

This task processes application sources before the optimizations take place in raw sources mode.

This involves following actions:processing of application's index.html template. <!-- visualBuilderScripts -->, <!-- vb:inject id="headContent" --> and <!-- vb:inject id="headContent" theme="resources/css/" --> markers are resolved to appropriate code. This step is done by vb-process-raw-index-html task.copies /services directory from root of visual application to the optimized web applicationupdates service references going outside of the application scope to local references referring the copy of /services directory in the web applicationcopies /dynamicLayouts directory from root of visual application to the optimized web application

The following table describes the subtasks, hooks and inputs and outputs of the vb-process-raw task.

Detail Description
subtasks vb-process-raw-index-html
multitask n/a
hooks n/a
input build/optimized/*
output build/optimized/*

The following table describes the options for the vb-process-raw task.

Name Mandatory Default Value Description
build no build Name of build directory.

vb-process-raw-index-html

This task resolves templating marks in an application's index.html.

This task removes the following templating marks:

  • <!-- visualBuilderScripts -->
  • <!-- vb:inject id="headContent" -->
  • <!-- vb:inject id="headContent" theme="resources/css/" -->

The following template variables are used in the code that replaces these markers:

  • %BASE_URL%
  • %JET_CDN_PATH%
  • %JET_CDN_VERSION%
  • %VB_CDN_PATH%
  • %VB_VERSION%

If the resolveTemplate configuration object is not provided for this task, these variables will be left unresolved in the resulting index.html.

If the resolveTemplate configuration object is set at least to empty object, the template variables will be resolved with values taken from the application's version files (private/custom/versions.json or resources/package/versions.json), or with default values if none of these exist. :

grunt.initConfig({
  "vb-process-raw-index-html": {
    options: {
      resolveTemplate: {
          BASE_URL: 'http://oracle.cloud/abc',
      }
    }
  },
});

The configuration object may also contain values for the other template variables. In such case, the configuration value has precedence before the versions files and defaults.

The following table describes the subtasks, hooks and inputs and outputs of the vb-process-raw-index-html task.

Detail Description
subtasks n/a
multitask config generator task: _vb-process-raw-index-configuration
hooks n/a
input build/optimized/*
output build/optimized/*

The following table describes the options for the vb-process-raw-index-html task.

Name Mandatory Default Value Description
build no build Name of build directory.
resolveTemplate no n/a Values for template variables injected into the application's index.html