build
steal-tools.build
Build a module and all of its dependencies and, optionally, other bundles to progressively load.
stealTools.build(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> | Stream<BuildResult>}
Either a Promise that resolves when the build is complete or a Stream that will send data events every time a rebuild is complete. By default a Promise is returned, unless the watch option is enabled.
Use
The following uses steal-tool's
buildmethod 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:
bundleSteal
Setting the
bundleStealoption totrueincludes steal.js and the configMain in each main bundle. This means one fewer http request.This will build bundles like:
To load the bundles, a html page should have a script tag like:
dest
The
destoption specifies a folder where the distributables (which includes your bundles, a production version of Steal, and possibly other assets).This will build bundles like:
To load the bundles, a html page should have a script tag like:
ignore
The
ignoreoption specifies which modules exclude from being bundled. A typical scenario for usingignoreis if you want a dependent module loaded from a CDN. The browser can load e.g. jQuery from the browsers cache. This saves traffic and also speed up your site.If you exclude a module from the bundled file, you have to make sure, that in the production environment configuration the module is:
... mapped to the pseudo-module @empty if you don't need it in production environment
... configured to the right location of the module e.g. a CDN
Multi-page use
The following uses steal-tool's
buildmethod to programatically build out the "login" and "homepage" modules as bundles.Assuming that "login" and "homepage" need the same modules, the following bundles will be created:
To load the homepage JS, CSS and the shared JS and CSS, an html page should have a script tag like:
Source Maps
Source maps provide a way to debug your bundled application. Using steal-tool's
buildyou can generate source maps like so:This will build out your application to
dist/bundles/app.jsand a corresponding source map will be atdist/bundles/app.js.map. Now load your application:And look in your debugger tools, the original sources should be shown and are debuggable.
These source maps are light-weight because they only include mappings back to the original sources; the original source files are still loaded by the browser. If you have a production environment where the original source files cannot be accessed, or you want to limit the number of requests made, you can set the
sourceMapsContentoption totrueand the original sources will be packaged along in theapp.js.mapfile.