scripts.md
April 16, 2014 ยท View on GitHub
var scripts = build.scripts(nodes, [options])
options (in addition to builder options):
sourceMap- enable source maps. Disabled by default. Not really working yet! sourceURL- enable source URLs. Defaults to development.alias- alias components with their shortnames. Allows you to require()components outside the build without worrying about versions. Defaults todevelopment.
Note that the require() implementation is not included in the build.
You can access it at build.scripts.require, or as the npm module component-require2.
For example:
build.scripts(node, options)
.use()
.end(function (err, string) {
fs.writeFile('build.build.js', build.scripts.require + string);
})
build.scripts.require
The require() implementation used by Component. You must include this in your built JS yourself.
var canonical = build.scripts.canonical(tree)
Return the JS entry point of a tree, allowing you to require(canonical) in the build.
var js = build.scripts.umd(canonical, alias, js)
UMD-wrap JS with the given canonical name derived from build.scripts.canonical(), a global alias name, and the js without the require implementation.
Plugins
The script builder's file objects have the following additional properties:
resolvePath-.pathrelative to the component's.main.name- the name of this file will be registered as in therequirebuild.
Note: file.string must be populated for a file to be included in the build.
js()
Includes a file as regular Javascript. Checks syntax errors as well.
build.scripts()
.use('scripts', builder.plugins.js());
json()
Includes a file as JSON. Will throw on invalid JSON.
build.scripts()
.use('json', builder.plugins.json());
string()
Includes a file as a string.
build.scripts()
.use('templates', builder.plugins.string());
Other
- html-minifier - minifies your HTML templates
- builder-es6-module-to-cjs - es6 module to cjs compiler
- jade
- regenerator - compiles generators to ES5
- coffee