Skip to content

Instantly share code, notes, and snippets.

@dan-gamble
Created November 12, 2014 22:02
Show Gist options
  • Save dan-gamble/4386f86ba1159857bbdb to your computer and use it in GitHub Desktop.
Save dan-gamble/4386f86ba1159857bbdb to your computer and use it in GitHub Desktop.
var gulp = require('gulp');
var browserSync = require('browser-sync')
var compass = require('gulp-compass');
var concat = require('gulp-concat');
var changed = require('gulp-changed');
var jshint = require('gulp-jshint');
var imagemin = require('gulp-imagemin');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var stripDebug = require('gulp-strip-debug');
var uglify = require('gulp-uglify');
var config = {
paths: {
css: {
src: ["my_goals/static/src/css/**/*.css"],
dest: "my_goals/static/build/css"
},
html: {
src: ["my_goals/templates/**/*.html"]
},
images: {
src: ['my_goals/static/src/img/**/*'],
dest: "my_goals/static/build/img"
},
javascript: {
src: ["my_goals/static/src/js/**/*.js"],
dest: "my_goals/static/build/js"
},
sass: {
src: ["my_goals/static/src/scss/**/*.scss"],
dest: "my_goals/static/build/css"
}
}
}
gulp.task('jshint', function() {
gulp.src(config.paths.javascript.src)
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('imagemin', function() {
gulp.src(config.paths.images.src)
.pipe(changed(config.paths.images.dest))
.pipe(imagemin())
.pipe(gulp.dest(config.paths.images.dest));
});
gulp.task('scripts', function() {
gulp.src(config.paths.javascript.src)
.pipe(concat('app.js'))
.pipe(stripDebug())
.pipe(uglify())
.pipe(gulp.dest(config.paths.javascript.dest));
});
gulp.task('sass', function() {
gulp.src(config.paths.sass.src)
.pipe(sourcemaps.init())
.pipe(sass())
.pipe(sourcemaps.write())
.pipe(gulp.dest(config.paths.sass.dest));
});
gulp.task('compass', function() {
gulp.src(config.paths.sass.src)
.pipe(compass({
config_file: 'my_goals/static/src/config.rb',
css: 'my_goals/static/src/css',
sass: 'my_goals/static/src/scss'
}))
.pipe(gulp.dest(config.paths.sass.dest));
});
gulp.task('watch', function() {
gulp.watch(config.paths.javascript.src, ['jshint', 'scripts']);
gulp.watch(config.paths.sass.src, ['compass']);
});
gulp.task('browser-sync', function() {
var files = [
config.paths.css.src,
config.paths.html.src,
config.paths.images.src,
config.paths.javascript.src
];
browserSync.init(files, {
proxy: '127.0.0.1:8000'
})
})
gulp.task('default', ['compass', 'browser-sync'], function() {
gulp.watch(config.paths.sass.src, ['compass']);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment