Customize Optimization

When your extension is shared or deployed, 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 shared or deployed. 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 deploying your extension.
  1. Click Menu in the upper right corner and select Settings.
  2. Click Create Build Configuration under Optimization to create the build.json file. If the file already exists, click Open Build Configuration.
  3. Define your build configuration in the build.json editor 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.json under the optimize element:
    Property Description
    optimize.suppress (Boolean) If set to true, optimization is disabled. If the property is not defined or is set to false, 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 is false, meaning resources are always optimized before the extension is shared or deployed.

    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
          ids
    optimize.require-js.vb-bundles-config.bundle_name.modules Modules that should be added to the bundle, defined using this schema:
      find
      ids
    optimize.require-js.vb-bundles-config.bundle_name.exclude Modules that should not be added to the bundle, defined using this schema:
      find
      ids
    Exclusions are applied to all bundle modules, including those added following transitive module dependencies.
    optimize.require-js.vb-bundles-config.bundle_name.[exclude|modules].find List 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].ids List 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.js into build.json, so your custom configuration can take effect during resource optimization when your extension is shared or deployed. The configuration in build.json is similar to what you define in Gruntfile.js. See How to Migrate Gruntfile.js Configuration Into build.json.