Search code examples
webpacklessautoprefixer

Is there a way to add prefixes to LESS file without compiling it into CSS?


I tried autoprefixer and less-plugin-autoprefix, but it seems that both of them adding the prefixes after the conversion to CSS


Solution

  • I ended up using postcss-less with autoprefixer

    const gulp = require('gulp');
    const postcss = require('gulp-postcss');
    const syntax = require('postcss-less');
    const autoprefixer = require('autoprefixer');
    
    gulp.task('default', () =>
      gulp.src('less/*.less')
      .pipe(postcss([
        autoprefixer({ browsers: ['last 2 versions'] })
      ], { syntax }))
      .pipe(gulp.dest('build/less'))
    );