optimize
steal-tools.optimize
Build a module and all of its dependencies and, optionally, other bundles to progressively load.
stealTools.optimize(config, options)
Parameters
-
config
{StealConfig}
Specifies configuration values to set on Steal's loader.
-
options
{BuildOptions}
OptionalSpecifies the behavior of the build.
Returns
{Promise<BuildResult>}
Promise that resolves when the build is complete.
Use
The following uses steal-tool's
optimize
method to programatically build out the "my-app" module as bundles.This will build bundles like:
To load the bundles, a html page should have a script tag like:
splitLoader
Setting the
splitLoader
option totrue
creates a bundle that only includes the code of the optimized loader shim.This will build bundles like:
To load the bundles, a html page should have a script tag that loads the loader and one that loads the application code:
The optimized loader can handle async loading, which means order is not relevant when adding the script tags.
dest
The
dest
option specifies a folder where the distributables (which includes your bundles and possibly other assets) are written.This will build bundles like:
To load the bundles, a html page should have a script tag like: