B
B
bloh_creator2019-12-19 10:36:21
Node.js
bloh_creator, 2019-12-19 10:36:21

Gulp throws an error when including an autoprefixer. What is the problem?

I'm trying to run. Gives an error message. I can not understand what she refers to? Google did not help.
The code itself

const gulp = require("gulp");
const sass = require("gulp-sass");
const less = require("gulp-less");
const stylus = require("gulp-stylus");
const sourcemaps = require("gulp-sourcemaps");
const autoprefixer = require("gulp-autoprefixer");



//sass
gulp.task('sasS', function() {
    return gulp.src('./scss/*.scss')
        .pipe(sourcemaps.init())
        .pipe(sass())
        .pipe(autoprefixer({
            browsers: ['last 2 versions'],
            cascade: false
        }))
        .pipe(sourcemaps.write())
        .pipe(gulp.dest('./css/'))
});

//less
gulp.task('lesS', function() {
    return gulp.src('./less/*.less')
        .pipe(sourcemaps.init())
        .pipe(less())
        .pipe(autoprefixer({
            browsers: ['last 2 versions'],
            cascade: false
        }))
        .pipe(sourcemaps.write())
        .pipe(gulp.dest('./css/'))
});

//stylus
gulp.task('stylusS', function() {
    return gulp.src('./stylus/*.styl')
        .pipe(sourcemaps.init())
        .pipe(stylus())
        .pipe(autoprefixer({
            browsers: ['last 2 versions'],
            cascade: false
        }))
        .pipe(sourcemaps.write())
        .pipe(gulp.dest('./css/'))
});




gulp.task('default', gulp.parallel('sasS', 'lesS', 'stylusS'));

Error:
D:\untitled\node_modules\gulp-autoprefixer\index.js:21
(async () => {
^
SyntaxError: Unexpected token (
at Object.exports.runInThisContext (vm.js:78:16)
at Module._compile (module.js:543:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12 )
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.(D:\untitled \gulpfile.js:6:22)
at Module._compile(module.js:571:32)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vyach Gor, 2019-12-19
@bloh_creator

if I'm not mistaken, when I was using version 3 of gulp, the gulp-autoprefixer plugin recommended removing (moving to package.json) the property "browsers: ['last 2 versions']" , maybe in 4 it already causes an error. Try to reschedule. I'll add a screenshot for clarity.
5dfb400be72ab665508614.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question