-
-
Save andyyou/f35a308e469348df4cc7 to your computer and use it in GitHub Desktop.
A common tasks of gulpfile.js
This file contains 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 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({ | |
root: ['playground'], | |
livereload: true | |
}); | |
}); | |
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