Created
September 12, 2014 21:50
-
-
Save cvan/f89a9d18310a7af28898 to your computer and use it in GitHub Desktop.
using duo with gulp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var duo = require('duo'); // https://github.com/duojs/duo | |
var map = require('map-stream'); // https://github.com/dominictarr/map-stream | |
var paths = { | |
build: { | |
src: { | |
jsApp: ['./src/js/main.js'], | |
jsClient: ['./src/js/client.js'] | |
}, | |
dest: { | |
js: './src' | |
} | |
} | |
}; | |
gulp.task('js-build', function () { | |
gulp.src(paths.build.src.jsApp) | |
.pipe(duoify()) | |
.pipe(gulp.dest(paths.build.dest.js)); | |
gulp.src(paths.build.src.jsClient) | |
.pipe(duoify()) | |
.pipe(gulp.dest(paths.build.dest.js)); | |
}); | |
function duoify(opts) { | |
opts = opts || {}; | |
return map(function (file, cb) { | |
duo(__dirname) | |
.entry(file.path) | |
.run(function (err, src) { | |
if (err) { | |
return cb(err); | |
} | |
file.contents = new Buffer(src); | |
cb(null, file); | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is nice! 👍