Skip to content

Instantly share code, notes, and snippets.

@hellobrian
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hellobrian/a6bb03d3a26faf90a480 to your computer and use it in GitHub Desktop.
Save hellobrian/a6bb03d3a26faf90a480 to your computer and use it in GitHub Desktop.
gulp
var gulp = require('gulp');
var plumber = require('gulp-plumber');
var sass = require('gulp-sass');
var webserver = require('gulp-webserver');
var autoprefixer = require('gulp-autoprefixer');
var sourcePaths = {
styles: ['scss/**/*.scss']
};
var distPaths = {
styles: 'public/css'
};
var server = {
host: 'localhost',
port: '3000'
}
// Compile scss files to css
gulp.task('sass', function () {
gulp.src( sourcePaths.styles )
.pipe(plumber())
.pipe(sass())
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: true
}))
.pipe(gulp.dest( distPaths.styles ));
});
// Run a local webserver
gulp.task('webserver', function() {
gulp.src('.')
.pipe(webserver({
host: server.host,
port: server.port,
livereload: true,
directoryListing: false
}));
});
gulp.task('watch', function() {
gulp.watch(sourcePaths.styles, ['sass']);
});
gulp.task('build', ['sass']);
gulp.task('default', ['build', 'webserver', 'watch']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment