Last active
August 29, 2015 13:56
-
-
Save ericdouglas/8855147 to your computer and use it in GitHub Desktop.
test gulpfile
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 | |
| gulp = require('gulp'), | |
| jade = require('gulp-jade'), | |
| stylus = require('gulp-stylus'), | |
| jshint = require('gulp-jshint'), | |
| concat = require('gulp-concat'), | |
| uglify = require('gulp-uglify'), | |
| rename = require('gulp-rename'); | |
| gulp.task('jade', function () { | |
| gulp.src('./*.jade') | |
| .pipe(jade({ | |
| pretty:true | |
| } | |
| )) | |
| .pipe(gulp.dest('./public')); | |
| }); | |
| gulp.task('stylus', function () { | |
| gulp.src('./*.styl') | |
| .pipe(stylus()) | |
| .pipe(gulp.dest('./public/css')); | |
| }); | |
| gulp.task('lint', function () { | |
| return gulp.src('js/*.js') | |
| .pipe(jshint()) | |
| .pipe(jshint.reporter('default')); | |
| }); | |
| // Concatenate and minify .js | |
| gulp.task('scripts', function () { | |
| return gulp.src('js/*.js') | |
| .pipe(concat('main.js')) | |
| .pipe(gulp.dest('public/js')) | |
| .pipe(rename('main.min.js')) | |
| .pipe(uglify()) | |
| .pipe(gulp.dest('public/js')); | |
| }); | |
| var EXPRESS_PORT = 4000; | |
| var EXPRESS_ROOT = __dirname; | |
| var LIVERELOAD_PORT = 35729; | |
| function startExpress() { | |
| var express = require('express'); | |
| var app = express(); | |
| app.use(require('connect-livereload')()); | |
| app.use(express.static(EXPRESS_ROOT)); | |
| app.listen(EXPRESS_PORT); | |
| } | |
| var lr; | |
| function startLivereload() { | |
| lr = require('tiny-lr')(); | |
| lr.listen(LIVERELOAD_PORT); | |
| } | |
| function startPlugins () { | |
| gulp.run('jade'); | |
| gulp.run('stylus'); | |
| gulp.run('lint'); | |
| gulp.run('scripts'); | |
| } | |
| function notifyLivereload(event) { | |
| gulp.src(event.path, {read: false}) | |
| .pipe(require('gulp-livereload')(lr)); | |
| } | |
| gulp.task('default', function () { | |
| startExpress(); | |
| startLivereload(); | |
| startPlugins(); | |
| gulp.watch('*.jade', ['jade']); | |
| gulp.watch(['public/*.html'], notifyLivereload); | |
| gulp.watch('*.styl', ['stylus']); | |
| gulp.watch(['public/css/*.css'], notifyLivereload); | |
| gulp.watch('js/*.js', ['lint', 'scripts']); | |
| gulp.watch(['public/js/*.js'], notifyLivereload); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment