Skip to content

Latest commit

 

History

History
76 lines (51 loc) · 2.34 KB

scripts.md

File metadata and controls

76 lines (51 loc) · 2.34 KB

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 to development.

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 - .path relative to the component's .main.
  • name - the name of this file will be registered as in the require build.

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