A simple build tool with a fluent interface
var jager = require('jager');
// create a new chain of actions
var livereload = jager.create()
('livereload'); // add a plugin to the chain
// create a chain which handles the javascript processing
var js = jager.create()
('src', 'jagerfile.js') // source of the chain
('uglify') // chain it to the uglify plugin
('rename', 'renamed-jagerfile.js') // rename the file
('dest', '.'); // write the file
// create tasks to execute the defined chains
jager.task('js', js);
// `{ watch: true }` is used to tell jager to rerun the task when
// any of the source files or its dependencies change
jager.task('watch:js', { watch: true }, js, livereload);
// create a chain to process the less files
var less = jager.create()
('src', 'main.less', { dependencies: '*.less' }) // specify a source file and a list of possible dependencies
('less') // chain it to the less plugin
('rename', 'main.css') // rename it
('autoprefixer') // call the autoprefixer plugin on it
('dest', '.'); // write the file
// create tasks for the less chains
jager.task('less', less);
jager.task('watch:less', { watch: true }, less, livereload);
// create a task for two chains, which will run simultaneously
jager.task('watch', { watch: true }, [js, less], livereload);
Install with npm install --save jager
and npm install -g jager
, after create a Jagerfile.js
file (see example above) in your project root. Then you can run jager [task]
to execute your task.
Alternatively you can skip the global install and use the version in node_modules/.bin/
, which is automatically added to your PATH
when you run it with npm run
. For example, the following package.json
script would run the watch task without the globally installed version.
{
"scripts": {
"watch": "jager watch"
}
}
Run with npm run watch
, no need for the global!
Plugins have pretty simple structure, like so:
module.exports = function(options) {
// the arguments to this function come from the `Jagerfile.js` file, for example:
// `('src', 'script.js')` would give the `'script.js'` as argument
return function(files, cb) {
// files contains an array with `jager.File` instances, which you can manipulate
cb(null, files);
};
};
Jager automatically loads plugins when they follow the convention that when the module name is jager-something-something
, it will load that plugin whenn you call it with ('something-something')
. You can also just pass the function you normally return in your plugin directly to Jager:
jager.create()
(function(files, cb) {
cb(null, files);
});
filename()
: Return the filename for the filecontents([string])
: When an argument is given, the contents are updated. Returns the contentsbuffer([buffer]))
: When an argument is given, the internal buffer is updated. Return the internal bufferstat([stat])
: When an argument is given, the stat is updated. Return the statrename(filename)
: Rename the file, the stat is updated to now
You can use both contents()
and buffer()
mixed, they will be converted on the fly when needed.
Jager has some builtin plugins to get you started:
src
: Add source filesdest
: Write filesbrowserify
: Process a file with browserifynewer
: Filter old files out of the chainuglify
: Uglify javascriptconcat
: Combine source filesrename
: Rename a fileless
: Process less filesautoprefixer
: Add vendor prefixes to cssangular-templates
: Create cache file for all angular templatesng-annotate
: Create a version of angular-js-file that is uglify savebower-src
: Add files from your bower configlivereload
: Reloads your browser when files changeimagemin
: Minify images seamlesslypostcss
: Transforming CSS with JS pluginsextract-sourcemap
: Extract sourcemaps into separate filesmodernizr
: Create on the fly modernizr buildsclean-css
: Library for minifying CSS files