A
A
Anton2016-09-05 08:43:45
gulp.js
Anton, 2016-09-05 08:43:45

Is it normal that my gulp-autoprefixer is looped and constantly looks at files?

9a82742a929044c6826d7cf92cacbdfe.png
Is it normal that my gulp-autoprefixer is looped and constantly looks at files?

var gulp = require('gulp'),
    less = require('gulp-less'),
    browserSync = require('browser-sync');
    autoprefixer = require('gulp-autoprefixer');

gulp.task('less', function(){
   return gulp.src('app/less/**/*.less')
   .pipe(less())
   .pipe(gulp.dest('app/css'))
   .pipe(browserSync.reload({stream: true}))
});

gulp.task('browser-sync', function(){
    browserSync({
        server:{
            baseDir: 'app'
        }
    });
});
gulp.task('gulp-autoprefixer', function(){
   return gulp.src('app/css/*.css')
   .pipe(autoprefixer({
            browsers: [
                'last 3 versions',
                '> 10%'
            ],
            cascade: false
        }))
   .pipe(gulp.dest('app/css/'))
});

gulp.task('watch',['browser-sync','less','gulp-autoprefixer'], function(){
    gulp.watch('app/less/**/*.less', ['less']);
    gulp.watch('app/css/**/*.css', ['gulp-autoprefixer']);
    gulp.watch('app/*.html', browserSync.reload);
    gulp.watch('app/ja/**/*.js', browserSync.reload);
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergei Nazarenko, 2016-09-06
@Ooos

better this way

gulp.task ('less', function(){
    return gulp.src('app/less/**/*.less')
      .pipe(less())
      .pipe(autoprefixer({
            browsers: [
                'last 3 versions',
                '> 10%'
            ],
            cascade: false
        }))
.pipe(gulp.dest('app/css'))
.pipe(browserSync.reload({stream: true})
});

gulp.watch('app/less/**/*.less', ['less']);

and then these lines are not needed at all
gulp.task('gulp-autoprefixer', function(){
return gulp.src('app/css/*.css')
.pipe(autoprefixer({
browsers: [
'last 3 versions',
'> 10%'
] ,
cascade: false
}))
.pipe(gulp.dest('app/css/'))
});
gulp.watch('app/css/**/*.css', ['gulp-autoprefixer']);

KISS & DRY - K eep I t S imple S tupid & D on't R epeat Y ourself

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question