Gulp pipelines and tasks to be shared between Metal components.
This is a collection of tasks to be used by Metal components. To use them, just install this through npm and register the tasks on your gulpfile like this:
var metal = require('gulp-metal'); metal.registerTasks(options);
As you can see, the metal function receives an optional object to customize the registered functions. Each task has its own options, but the
taskPrefix option affects all task, registering them all with the provided prefix before the original names.
After calling the metal function, several tasks will then be available to run on gulp. These can be broken in different categories, so we'll explain each separately.
As we've mentioned before, Metal.js is written in ES6. Since browsers don't yet implement ES6, the original code won't run on them. There are several different ways to solve this, such as adding a ES6 polyfill like traceur. That means adding more code to the page though, as well as compiling the code at run time.
Another option is to previously build the ES6 files to ES5 equivalents. Again, there are lots of ways to do this, and lots of formats to build to. Metal.js provides a few tasks as build options that can be used out of the box.
Builds your project's files: css, soy and js (from ES6 code to ES5 for example). The following options can be passed to the metal function for customizing this task:
buildDestThe directory where the built files should be placed. Default: build.
bundleFileNameThe name of the final bundle file. Only used for output formats that bundle all compiled code into a single file, like when building to globals. Default: metal.js.
buildSrcThe glob expression that defines which js files should be built. Default: src/**/*.js.
globalNameThe name of the global variable that should hold the exported values of the modules. Only used if the globals output format is being used. Default: metal.
mainBuildJsTasksThe tasks that should be run for building js. That's how you can choose the output format of the compiled js code. Default: build:globals:js.
Watches for changes on the source files, rebuilding the code to the chosen format automatically when that happens.
Metal.js also provides gulp tasks to help with testing modules built with Metal.js. The tasks assume that tests are written in karma, and so there should be a karma.conf.js file. A sample karma.conf.js file can be found at generator-metal, which works well with Metal.js, including correct coverage reports.
Runs all tests once.
Runs all tests once and shows coverage information on the terminal.
Runs all tests once and then opens the coverage html file on the default browser.
Runs all tests once on the following browsers: Chrome, Firefox, Safari, IE9, IE10 and IE11.
Runs all tests once on Saucelabs. Both username and access key need to be previously specified as environemnt variables for this to work. See karma-sauce-launcher for more details.
Watches for changes to source files, rerunning tests automatically when that happens.
corePathFromSoyThe path from the soy files location to Metal.js's core module. Default: metal/src.
soyDestThe directory where the compiled soy files should be placed. Default: src.
soyGeneratedDestThe directory that should hold the generated soy files. Default build.
soySrcThe glob expression that defines the location of the soy files. Default: src/**/*.soy.