Skip to content

Instantly share code, notes, and snippets.

@RinatMullayanov
Last active August 29, 2015 14:07
Show Gist options
  • Save RinatMullayanov/1563413cb066681ee746 to your computer and use it in GitHub Desktop.
Save RinatMullayanov/1563413cb066681ee746 to your computer and use it in GitHub Desktop.
Sample gulpfile.js with using express
var gulp = require('gulp'),
compass = require('gulp-compass'),
express = require('express'),
gutil = require('gulp-util'),
path = require('path'),
refresh = require('gulp-livereload'),
server = require('tiny-lr')();
gulp.task('expressServer', function(){
app = express();
app.use(require('connect-livereload')());
app.use(express.static('public/'));
app.listen(4000);
});
gulp.task('html', function(){
gulp.src('src/**/*.html')
.pipe(gulp.dest('public/'))
.pipe(refresh(server));
})
gulp.task('sass', function(){
gulp.src('src/stylesheets/**/*.sass')
.pipe(compass({ config_file: 'config.rb', sass: 'src/stylesheets/', css: 'public/assets/stylesheets/' }))
.pipe(gulp.dest('public/assets/stylesheets/'))
.pipe(refresh(server));
});
gulp.task('default', ['expressServer', 'html', 'sass'], function() {
server.listen(35729, function (error) {
if (error) return console.log(error);
gulp.watch('src/stylesheets/**/*.sass', function () {
gulp.run('sass');
});
gulp.watch('src/**/*.html', function () {
gulp.run('html');
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment