Last active
August 29, 2015 13:59
-
-
Save srikarg/5b48fa68f75ecf75bbcb to your computer and use it in GitHub Desktop.
A boilerplate gulpfile (http://gulpjs.com/). Features live reloading of SASS, CoffeeScript, and HTML.
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'); | |
var plugins = require('gulp-load-plugins')(); | |
plugins.connect = require('gulp-connect'); | |
plugins.jshint = require('gulp-jshint'); | |
var port = 4000; | |
gulp.task('styles', function() { | |
return plugins.rubySass('sass/main.scss', { style: 'compressed' }) | |
.pipe(plugins.autoprefixer('last 15 version')) | |
.pipe(plugins.rename({ suffix: '.min' })) | |
.pipe(gulp.dest('css')) | |
.pipe(plugins.connect.reload()); | |
// .pipe(plugins.notify({ message: 'Styles task complete.' })); | |
}); | |
gulp.task('scripts', function() { | |
return gulp.src('coffee/**/*.coffee') | |
.pipe(plugins.coffee({ bare: true })) | |
.pipe(plugins.concat('main.js')) | |
.pipe(plugins.jshint.reporter('default')) | |
.pipe(plugins.rename({ suffix: '.min' })) | |
.pipe(plugins.uglify()) | |
.pipe(gulp.dest('js')) | |
.pipe(plugins.connect.reload()); | |
// .pipe(plugins.notify({ message: 'Scripts task complete.' })); | |
}); | |
gulp.task('clean', function() { | |
return gulp.src(['css/*', '!css/lib', 'js/*', '!js/lib'], {read: false}) | |
.pipe(plugins.rimraf()); | |
// .pipe(plugins.notify({ message: 'Clean task complete.' })); | |
}); | |
gulp.task('connect', function() { | |
plugins.connect.server({ | |
port: port, | |
livereload: true | |
}); | |
}); | |
gulp.task('open', function() { | |
var options = { | |
url: 'http://localhost:' + port | |
}; | |
gulp.src('./index.html') | |
.pipe(plugins.open('', options)); | |
}); | |
gulp.task('html', function() { | |
gulp.src('index.html') | |
.pipe(plugins.connect.reload()); | |
}); | |
gulp.task('watch', function() { | |
gulp.watch('index.html', ['html']); | |
gulp.watch('sass/**/*.scss', ['styles']); | |
gulp.watch('coffee/**/*.coffee', ['scripts']); | |
}); | |
gulp.task('default', ['clean', 'styles', 'scripts', 'connect', 'open', 'watch']); |
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
npm install --save-dev gulp gulp-autoprefixer gulp-rimraf gulp-coffee gulp-concat gulp-connect gulp-jshint gulp-load-plugins gulp-notify gulp-open gulp-rename gulp-ruby-sass@1.0.0-alpha gulp-uglify |
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
{ | |
"name": "my_project", | |
"description": "description", | |
"author": "Srikar Gudipati", | |
"homepage": "http://srikarg.github.io/", | |
"version": "1.0.0", | |
"repository": { | |
"type": "git", | |
"url": "git://github.com/username/repository.git" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment