Skip to content

Instantly share code, notes, and snippets.

@kevinSuttle
Created November 25, 2014 17:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save kevinSuttle/d41119c006315e9790b9 to your computer and use it in GitHub Desktop.
Save kevinSuttle/d41119c006315e9790b9 to your computer and use it in GitHub Desktop.
gulp-ruby-sass and gulp-autoprefixer
'use strict';
// Include Gulp & Tools We'll Use
var gulp = require('gulp');
var sass = require('gulp-ruby-sass');
var browserSync = require('browser-sync');
var localConfig = require('./config/app.json');
var stylestats = require('gulp-stylestats');
var projectSize = require('gulp-size');
var autoprefixer = require('gulp-autoprefixer');
var AUTOPREFIXER_BROWSERS = [
'ie >= 10',
'ie_mob >= 10',
'ff >= 30',
'chrome >= 34',
'safari >= 7',
'opera >= 23',
'ios >= 7',
'android >= 4.4',
'bb >= 10'
];
// Build Production Files, the Default Task
gulp.task('default', ['serve', 'styles', 'browser-sync'], function() {
gulp.watch(['sass/**/*.scss'], ['styles']);
gulp.watch(['public/css/*.css}'], [browserSync.reload]);
});
// Locally sync devices on the same WiFi network
gulp.task('browser-sync', function(){
browserSync({
proxy: localConfig.host + ":" + localConfig.port,
open: false
})
})
// Compile SASS Stylesheets
gulp.task('styles', function () {
return sass('sass/')
.pipe(autoprefixer({
browsers: AUTOPREFIXER_BROWSERS,
cascade: false
}))
//.pipe(stylestats())
.pipe(gulp.dest('public/css'))
.pipe(projectSize({'showFiles': true, 'gzip': false}))
.pipe(projectSize({'showFiles': true, 'gzip': true}))
.pipe(browserSync.reload({stream: true}));
});
// Start Express Server
gulp.task('serve', function () {
var spawn = require('child_process').spawn;
var expressServer = spawn('npm', ['start'], {stdio: 'inherit'});
expressServer.on('exit', function (code) {
gulpCallBack(code === 0 ? null : 'ERROR: Express server process exited with code: ' + code);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment