M
M
Marie2015-01-16 10:51:54
JavaScript
Marie, 2015-01-16 10:51:54

How to properly write an autoprefixer task with stylus (Gulp)?

there is a task

var gulp = require('gulp'),
  stylus = require('gulp-stylus'),
  autoprefixer = require('gulp-autoprefixer');

gulp.task('styl',function() {
       return gulp.src('styl/*.styl')
      .on('error', console.log) 
      .pipe(stylus())
       .pipe(autoprefixer({
       	browsers: ['last 2 versions'],
                            	cascade: true
                }))
        	.pipe(gulp.dest('public/css/'))
        	.pipe(notify('CSS Done!'))
      .pipe(connect.reload());
    });

  gulp.task('watch', function() {
      gulp.watch('styl/*.styl', ['styl'])
      gulp.watch('jade/index.jade', ['jade'])
      gulp.watch('js/*.js',['js'])
    });

                gulp.task('do', ['watch','jade', 'styl', 'js', 'connect']);

here is a piece of the whole gulpfile (I think this is understandable).
and so, how it is correct to write that autoprefixer would work?
or maybe I don’t understand something, but he doesn’t put prefixes, I know that for sure)
Thanks in advance)
ps come on, I know that one of you knows for sure)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Taratin, 2015-01-16
@SavaMar

browsers: ['last 2 versions']

Are you sure you use properties that require prefixes in the last 2 versions of browsers?
keyframe try to insert somewhere. Will it work for him?

V
Victor, 2017-01-22
@vscnn

There is a version specifically for stylus: autoprefixer-stylus .
This, by the way, is written in the documentation for the autoprefixer:
As a result, it turns out something like this:

const autoprefixer = require('autoprefixer-stylus');
const stylus = require('gulp-stylus');

gulp.task('stylus', () => {
  gulp.src('./src/styl/style.styl')
  .pipe(stylus({
    pretty:true,
    use:[autoprefixer('last 2 versions')]
  }))
  .pipe(gulp.dest('./dist/css'))
  .pipe(connect.reload())
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question