How to Migrate Gruntfile.js
Configuration Into build.json
If you use Grunt tasks to optimize your application, it's important to migrate configuration you've already defined in the Gruntfile.js
file into build.json
. Without this definition in build.json
, resource optimization that occurs by default when your application is shared or deployed won't include your customizations.
- Select the web application in the Navigator, then click Settings to open the app-level Settings editor.
- Click Open Build Configuration under Optimization to open your application's build.json file. If you don't see this option, click Create Build Configuration to create the build.json file (under
/webApps/app_name/settings
) and open it from within the Settings editor. - Add this snippet to build.json:
{ "optimize": { "require-js": { "emptyPaths": [ ], "vb-bundles-config": { } } } }
- Open your application's
Gruntfile.js
file (located at the root of your visual application in Source view). - Move the following configuration from
Gruntfile.js
tobuild.json
:- Move the content of
vb-require-bundle.options.bundles
fromGruntfile.js
intooptimize.require-js.vb-bundles-config
inbuild.json
. - Move the content of
vb-require-bundle.options.emptyPaths
, if defined, fromGruntfile.js
intooptimize.require-js.emptyPaths
inbuild.json
.
Remember to fix the syntax for JSON schema. For example, here's a side-by-side comparison of the configuration inGruntfile.js
andbuild.json
:Gruntfile.js build.json 'use strict'; module.exports = (grunt) => { require('load-grunt-tasks')(grunt); grunt.initConfig({ "vb-require-bundle": { options: { emptyPaths: [ 'ckeditor', ], "bundles": { "vb-app-bundle": { "modules": { "find": [ "^flows/", "^pages/", "^resources/", "!^services/", ], }, }, }, }, }, }); };
{ "optimize": { "require-js": { "emptyPaths": [ "ckeditor" ], "vb-bundles-config": { "vb-app-bundle": { "modules": { "find": [ "^flows/", "^pages/", "^resources/", "!^services" ] } } } } } }
- Move the content of
- Remove
vb-require-bundle
fromGruntfile.json
, so your file looks something like this:module.exports = (grunt) => { require('load-grunt-tasks')(grunt); };