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 share or publish 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.jsfile (located at the root of your visual application in Source view). - Move the following configuration from
Gruntfile.jstobuild.json:- Move the content of
vb-require-bundle.options.bundlesfromGruntfile.jsintooptimize.require-js.vb-bundles-configinbuild.json. - Move the content of
vb-require-bundle.options.emptyPaths, if defined, fromGruntfile.jsintooptimize.require-js.emptyPathsinbuild.json.
Remember to fix the syntax for JSON schema. For example, here's a side-by-side comparison of the configuration inGruntfile.jsandbuild.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-bundlefromGruntfile.json, so your file looks something like this:module.exports = (grunt) => { require('load-grunt-tasks')(grunt); };