require-sugar
v0.1.4
Published
Syntactic sugar for defining AMD modules
Downloads
3
Readme
require-sugar
require-sugar is a simple preprocessor for JavaScript and CoffeeScript which provides a custom syntax for defining dependencies for RequireJS.
Example transformation
Original source:
### define
jquery : $
underscore : _
###
code()
Output source:
define(["jquery", "underscore"], function ($, _) {
code();
});
Installation
$ npm install require-sugar
Example integration with gulp
For JavaScript:
gulp.src(options.src.scripts)
.pipe(requireSugar()) // <--
.pipe(gulp.dest(options.dest.scripts));
CoffeeScript files should be processed as coffee-files and not as js-files. This leverages CoffeeScript's feature that the last statement is always returned.
gulp.src(options.src.scripts)
.pipe(requireSugar()) // <--
.pipe($.coffee())
.pipe(gulp.dest(options.dest.scripts));
License
MIT © scalable minds 2014