sweetbuild v0.2.0
sweetbuild
A Sweet.js DSL for Broccoli, the best frontend asset pipeline.
Usage
$ npm install --save-dev sweet.js sweetbuild broccoli broccoli-merge-trees
Put the following in Brocfile.js
:
require('sweet.js').loadMacro('sweetbuild');
module.exports = require('./Brocfile.sjs');
Put your build script in Brocfile.sjs
(or whatever you required in Brocfile.js
) and use Broccoli like you normally do.
The macros
brequire
A shorthand for require
.
Requires some_thing
from broccoli-some-thing
.
brequire source_map; // requires broccoli-source-map as source_map
+++ and +!+
Operators that merge trees using broccoli-merge-trees.
They are left-associative.
+!+
is the {overwrite: true}
version.
You can use both single trees and lists of trees at both sides.
var scripts = 'src' +++ 'vendor/src';
var styles = ['normalize', 'formalize'].map(function(x) {return 'bower_components/' + x}) +++ ['stylesheets', 'ie-stylesheets'] +!+ 'vendor/stylesheets';
->
The chain operator. Like the UNIX pipe for plugin calls. Best understood by example:
var scripts = 'src/main/coffee' -> coffee({bare: true}) -> uglify_js;
// same as:
var scripts = uglify_js(coffee('src/main/coffee', {bare: true}));
A complete example
brequire coffee;
brequire uglify_js;
brequire sass;
brequire manifest;
var scripts = 'vendor/js' +++ ('cs' -> coffee)
-> uglify_js;
var styles = 'vendor/css' +++ ('vendor/sass' +++ 'sass'
-> sass('main.scss', 'main.css'));
var assets = scripts +++ styles;
module.exports = assets +++ manifest(assets);
License
Copyright © 2014 myfreeweb This work is free. You can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See the COPYING file for more details.