0.1.4 • Published 10 years ago

require-sugar v0.1.4

Weekly downloads
4
License
MIT
Repository
github
Last release
10 years ago

require-sugar build status

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