Skip to content

Instantly share code, notes, and snippets.

@andyyou
Created September 17, 2014 12:08
Show Gist options
  • Select an option

  • Save andyyou/d3a5f9ef1cc7d6fcebfa to your computer and use it in GitHub Desktop.

Select an option

Save andyyou/d3a5f9ef1cc7d6fcebfa to your computer and use it in GitHub Desktop.
The question?
var gulp = require("gulp"),
connect = require("gulp-connect"),
less = require("gulp-less"),
react = require("gulp-react"),
watch = require("gulp-watch"),
jade = require("gulp-jade"),
clean = require("gulp-clean");
/**
* Compilers
*/
gulp.task("less", ["clean-css"], function () {
gulp.src("playground/src/styles/less/*.less")
.pipe(less())
.pipe(gulp.dest("playground/dist/css"));
});
gulp.task("clean-css", function () {
gulp.src("playground/dist/css/*", {read: false}).pipe(clean({force: true}));
});
gulp.task("jsx", ["clean-js"], function () {
gulp.src("playground/src/scripts/jsx/*.jsx")
.pipe(react())
.pipe(gulp.dest("playground/dist/js/"));
});
gulp.task("clean-js", function () {
gulp.src("playground/dist/js/*", {read: false}).pipe(clean({force: true}));
});
gulp.task("jade", ["clean-html"], function () {
gulp.src("playground/src/templates/**.jade")
.pipe(jade())
.pipe(gulp.dest("playground"));
});
gulp.task("clean-html", function () {
gulp.src("playground/*.html", {read: false}).pipe(clean({force: true}));
});
/*********************************************************/
/**
* Web Server
*/
gulp.task("server", function () {
connect.server({
livereload: true,
root: ["build", "playground"],
});
});
gulp.task("livereload", function () {
watch(["playground/*.html", "playground/dist/**"])
.pipe(connect.reload());
});
gulp.task("watch", function () {
gulp.watch("playground/src/styles/less/*.less", ["less"]);
gulp.watch("playground/src/scripts/jsx/*.jsx", ["jsx"]);
gulp.watch("playground/src/templates/**.jade", ["jade"]);
});
/*********************************************************/
/**
* Mixin feature for usages
*/
gulp.task("default", ["less", "jsx", "jade", "server", "livereload", "watch"]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment