Skip to content

Instantly share code, notes, and snippets.

@darlanalves
Forked from anonymous/gulp-build-module.js
Created August 1, 2014 01:37
Show Gist options
  • Save darlanalves/99c21cb7eeaefc1147e6 to your computer and use it in GitHub Desktop.
Save darlanalves/99c21cb7eeaefc1147e6 to your computer and use it in GitHub Desktop.
var gulp = require('gulp'),
concat = require('gulp-concat'),
wrap = require('gulp-wrap'),
multipipe = require('multipipe'),
spaceRe = /\s+/g,
wrapper = '(function(undefined){\n\n<%= contents %>\n}());';
module.exports = function buildModule(src, dest, watch) {
var name = String(src).replace(spaceRe, '-');
function task() {
var pipe = multipipe(
gulp.src(src),
concat(),
wrap(wrapper),
gulp.dest(dest)
);
pipe.on('error', function(err) {
console.warn(err);
});
}
gulp.task(name, task);
gulp.watch(watch, name);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment