Customize Optimization
When your extension is share or deploy, all its resources are optimized to improve performance. If you want to specify the resources you want to include and exclude in the optimized resources bundle, you can define your own optimization configuration in a build.json file.
Optimization, by default, includes all resources that match the regular expression .*(\\.(js|json|html|css))$ in an optimized resources bundle named vb-app-bundle. During this process, stylesheets, HTML, and JSON files are minified, and RequireJS bundles created in the embedded build server that prepares your extension to be share or deploy. To customize this configuration to include and exclude resources, you’ll need to create a build.json file and define your own configuration before sharing or publishing your extension.
-
Click Menu in the upper right corner and select Settings.
-
Click Create Build Configuration under Optimization to create the
build.jsonfile. If the file already exists, click Open Build Configuration. -
Define your build configuration in the
build.jsoneditor to specify the resources you want to include in and exclude from the optimized resources bundle.Here's the schema you must use to define optimization in
build.jsonunder theoptimizeelement:Property Description optimize.suppress(Boolean) If set to true, optimization is disabled. If the property is not defined or is set tofalse, optimization is determined by the Optimize Application setting defined in a Packaging build step, or by individual optimizer settings (for example,optimize.require-js.enable). Default isfalse, meaning resources are always optimized before the extension is share or deploy .It's simpler to disable optimization from the Settings editor, instead of manually editing
build.json. See Suppress Optimization .optimize.require-js(Object) Configuration of the RequireJS optimizer that generates resource bundles. optimize.require-js.enable(Boolean) Whether RequireJS module bundles should be created. Enabled by default. optimize.require-js.vb-bundles-config(Object) Custom RequireJS module bundles, defined using this schema: <bundle_name> find ids modules find ids exclude find idsoptimize.require-js.vb-bundles-config. bundle_name .modulesModules that should be added to the bundle, defined using this schema: find idsoptimize.require-js.vb-bundles-config. bundle_name .excludeModules that should not be added to the bundle, defined using this schema:
Exclusions are applied to all bundle modules, including those added following transitive module dependencies.find idsoptimize.require-js.vb-bundles-config. bundle_name .[exclude|modules].findList of regular expression patterns used for matching optimized application resources. Regular expressions starting with an exclamation mark (!) are considered negative; resources matching these patterns won't be included. optimize.require-js.vb-bundles-config. bundle_name .[exclude|modules].idsList of module IDs optimize.require-js.emptyPaths(Array) Comma-separated list of RequireJS paths that are set to empty. This way, you indicate that this dependency must be ignored (and also that its sub-dependencies must not be recursively traversed).optimize.css(Object) Whether stylesheets should be optimized. Enabled by default. optimize.css.enable(Boolean) Set to false to disable stylesheet optimization. optimize.html(Object) Whether HTML files should be optimized. Enabled by default. optimize.html.enable(Boolean) Set to false to disable HTML file optimization. optimize.json(Object) Whether JSON files should be optimized. Enabled by default. optimize.json.enable(Boolean) Set to false to disable JSON file optimization. For default and other example configurations, see Optimization Configurations for build.json.
Tip: If you use Grunt tasks to optimize your app, you must migrate your existing Grunt configuration from
Gruntfile.jsintobuild.json, so your custom configuration can take effect during resource optimization when your extension is share or deploy. The configuration inbuild.jsonis similar to what you define inGruntfile.js. See How to Migrate Gruntfile.js Configuration Into build.json.