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 extension is share or deploy won't include your customizations.
- Click Menu in the upper right corner and select Settings.
- Click Open Build Configuration under Optimization to open your extension's build.json file. If you don't see this option, click Create Build Configuration to create the build.json file (under
/extension1/sources/settings) and open it from within the Settings editor. - Add this snippet to build.json:
{ "optimize": { "require-js": { "emptyPaths": [ ], "vb-bundles-config": { } } } } - Open your extension's
Gruntfile.jsfile (located at the root of your extension 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); };