Skip to content

Instantly share code, notes, and snippets.

@pixiebox
Created October 3, 2016 14:38
Show Gist options
  • Save pixiebox/b8bd3cc3a7282608450b1cf15b2c5c56 to your computer and use it in GitHub Desktop.
Save pixiebox/b8bd3cc3a7282608450b1cf15b2c5c56 to your computer and use it in GitHub Desktop.
// Deep Breaths //
//////////////////
// Gulp
var gulp = require('gulp');
// Sass/CSS stuff
var sass = require('gulp-sass');
var prefix = require('gulp-autoprefixer');
var minifycss = require('gulp-minify-css');
// JavaScript
var uglify = require('gulp-uglify');
// Images
var svgmin = require('gulp-svgmin');
var imagemin = require('gulp-imagemin');
// Stats and Things
var size = require('gulp-size');
//
// compile all your Sass
gulp.task('sass', function (){
gulp.src(['./dev/sass/*.scss', '!./dev/sass/_variables.scss'])
.pipe(sass({
includePaths: ['./dev/sass'],
outputStyle: 'expanded'
}))
.pipe(prefix(
"last 1 version", "> 1%", "ie 8", "ie 7"
))
.pipe(gulp.dest('./dev/css'))
.pipe(minifycss())
.pipe(gulp.dest('./prod/css'));
});
// Uglify JS
gulp.task('uglify', function(){
gulp.src('./dev/js/*.js')
.pipe(uglify())
.pipe(gulp.dest('./prod/js'));
});
// Images
gulp.task('svgmin', function() {
gulp.src('./dev/img/svg/*.svg')
.pipe(svgmin())
.pipe(gulp.dest('./dev/img/svg'))
.pipe(gulp.dest('./prod/img/svg'));
});
gulp.task('imagemin', function () {
gulp.src('./dev/img/**/*')
.pipe(imagemin())
.pipe(gulp.dest('./dev/img'))
.pipe(gulp.dest('./prod/img'));
});
// Stats and Things
gulp.task('stats', function () {
gulp.src('./prod/**/*')
.pipe(size())
.pipe(gulp.dest('./prod'));
});
//
gulp.task('default', function(){
// watch me getting Sassy
gulp.watch("./dev/sass/**/*.scss", function(event){
gulp.run('sass');
});
// make my JavaScript ugly
gulp.watch("./dev/js/**/*.js", function(event){
gulp.run('uglify');
});
// images
gulp.watch("./dev/img/**/*", function(event){
gulp.run('imagemin');
gulp.run('svgmin');
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment