Answer the question
In order to leave comments, you need to log in
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']);
Answer the question
In order to leave comments, you need to log in
browsers: ['last 2 versions']
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 questionAsk a Question
731 491 924 answers to any question