I have only recently been getting these errors where my Gulp is saying that i need to change my gulp-autoprefixer to postcss.
But since i only got this gulpfile with the Quench generator i have no idea how to change it so what autoprefixer will work again. Can anyone tell me in detail how to change this?
My gulpfile is:
var gulp = require('gulp'),
plumber = require('gulp-plumber'),
rename = require('gulp-rename');
var autoprefixer = require('gulp-autoprefixer');
var minifycss = require('gulp-minify-css');
var sass = require('gulp-sass');
var browserSync = require('browser-sync');
gulp.task('browser-sync', function() {
browserSync({
server: {
baseDir: "./"
}
});
});
gulp.task('bs-reload', function () {
browserSync.reload();
});
gulp.task('styles', function(){
gulp.src(['src/css/*.scss'])
.pipe(plumber({
errorHandler: function (error) {
console.log(error.message);
this.emit('end');
}}))
.pipe(sass())
.pipe(autoprefixer('last 2 versions'))
.pipe(gulp.dest('assets/css/'))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.pipe(gulp.dest('assets/css/'))
.pipe(browserSync.reload({stream:true}))
});
gulp.task('default', ['browser-sync'], function(){
gulp.watch("src/css/*.sass", ['styles']);
gulp.watch("src/css/*.scss", ['styles']);
gulp.watch("*.html", ['bs-reload']);
});
My package.json:
"name": "Quench",
"version": "1.0.0",
"description": "A Gulp file and project generator.",
"main": "gulpfile.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Quench",
"license": "ISC",
"devDependencies": {
"browser-sync": "2.6.5",
"gulp": "3.8.11",
"gulp-autoprefixer": "2.1.0",
"gulp-babel": "5.1.0",
"gulp-concat": "2.5.2",
"gulp-minify-css": "1.0.0",
"gulp-plumber": "1.0.0",
"gulp-rename": "1.2.2",
"gulp-sass": "^3.1.0",
"gulp-uglify": "^3.0.0"
}
}
install these packages
npm i --save-dev gulp-postcss autoprefixer cssnano
cssnano is postcss version of minify change your gulp code
var gulp = require('gulp'),
plumber = require('gulp-plumber'),
rename = require('gulp-rename');
//var autoprefixer = require('gulp-autoprefixer'); /*remove*/
//var minifycss = require('gulp-minify-css'); /*remove*/
var postcss = require('gulp-postcss'); /*add*/
var autoprefixer = require('autoprefixer'); /*add*/
var cssnano = require('cssnano'); /*add*/
var sass = require('gulp-sass');
var browserSync = require('browser-sync');
gulp.task('browser-sync', function() {
browserSync({
server: {
baseDir: "./"
}
});
});
gulp.task('bs-reload', function () {
browserSync.reload();
});
gulp.task('styles', function(){
/*add this*/
var processors = [
autoprefixer,
cssnano
];
gulp.src(['src/css/*.scss'])
.pipe(plumber({
errorHandler: function (error) {
console.log(error.message);
this.emit('end');
}}))
.pipe(sass())
//.pipe(autoprefixer('last 2 versions')) /*remove*/
.pipe(postcss(processors)) /*add*/
.pipe(gulp.dest('assets/css/'))
.pipe(rename({suffix: '.min'}))
// .pipe(minifycss()) /*remove*/
.pipe(gulp.dest('assets/css/'))
.pipe(browserSync.reload({stream:true}))
});
this should do the trick, if not i will look over it again