vendredi 27 juin 2014

How can we run Autoprefixer after "compass watch" using Gulp?


Vote count:

0




I want to take advantage of running autoprefixer after compass watches for changes to my scss files and update the css file with the autoprefixed code, but I'm stuck. I created a gulp.task in gulpfile.js for compass and autoprefixer. When I run "gulp server" using the gulpfile.js below everything works but no autoprefixing; the scss files are run through compass and output as a css file and browserSync live-reloads the page in the browser. Any help would be greatly appreciated.



'use strict';

var gulp = require('gulp');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var paths = require('compass-options').paths();
var rename = require('gulp-rename');
var autoprefixer = require('gulp-autoprefixer');
var browserSync = require('browser-sync');
var shell = require('gulp-shell');

//////////////////////////////
// Begin Gulp Tasks
//////////////////////////////
gulp.task('lint', function () {
return gulp.src([
paths.js + '/**/*.js',
'!' + paths.js + '/**/*.js'
])
.pipe(jshint())
.pipe(jshint.reporter(stylish))
});

//////////////////////////////
// Compass Task
//////////////////////////////
gulp.task('compass', function () {
return gulp.src(paths.sass + '/**/*')
.pipe(shell([
'bundle exec compass watch --time'
]));
});

//////////////////////////////
// Autoprefixer
//////////////////////////////
gulp.task('prefix', function() {
return gulp.src('css/style.css')
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
.pipe(gulp.dest('css'));
});

//////////////////////////////
// Watch
//////////////////////////////
gulp.task('watch', function () {
gulp.watch(paths.js + '/**/*.js', ['lint']);
});

//////////////////////////////
// BrowserSync Task
//////////////////////////////
gulp.task('browserSync', function () {
browserSync.init([
paths.css + '/**/*.css',
paths.js + '/**/*.js',
paths.img + '/**/*',
paths.fonts + '/**/*',
paths.html + '/**/*.html',
]);
});

//////////////////////////////
// Server Tasks
//////////////////////////////
gulp.task('server', ['watch', 'compass', 'browserSync']);


asked 39 secs ago






Aucun commentaire:

Enregistrer un commentaire