How can we run Autoprefixer after "compass watch" using Gulp? -
i want take advantage of running autoprefixer after compass watches changes scss files , update css file autoprefixed code, i'm stuck. created gulp.task in gulpfile.js compass , autoprefixer. when run "gulp server" using gulpfile.js below works no autoprefixing; scss files run through compass , output css file , browsersync live-reloads page in browser. 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']);
like @tmack mentioned must use autoprefixer in same task. here example 1 of projects (i use gulp-compass compiling):
var compass = require('gulp-compass'), autoprefixer = require('gulp-autoprefixer'); // styles gulp.task('styles', function() { return gulp.src(['src/styles/main.scss']) .pipe(compass({ sass : 'src/styles', css : 'dist/styles', logging : false, comments : false, style : 'expanded' })) .pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'ff 17', 'opera 12.1', 'ios 6', 'android 4')) .pipe(gulp.dest('dist/styles')); }); ciao ralf
Comments
Post a Comment