regeneratorRuntime is not defined with gulp

13 views Asked by At

I'm trying to use an asynchronous function and it's giving me the following error 'regeneratorRuntime is not defined'. I saw a possible solution, but it's for webpack, I'm using gulp, can anyone help me?

I'm using gulp version 4.0.2

This was the solution I found for webpack, can anyone help me adjust this for gulp, please? Babel 6 regeneratorRuntime is not defined

The code below is the gulpfile.js file

// Load modules
const config = require('./.core/config.json');
const rename = require('gulp-rename');
const gulp = require('gulp');
const sass = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
const browserSync = require('browser-sync').create();
const concat = require('gulp-concat');
const babel = require('gulp-babel');
const uglify = require('gulp-uglify');
const imagemin = require('gulp-imagemin');
const webp = require('gulp-webp');
const minify = require('gulp-minify');
const gzip = require('gulp-gzip');
const robots = require('gulp-robots');
var awspublish = require('gulp-awspublish');

function generateRobots() {
    gulp.task('default', function () {
        gulp.src('index.html')
            .pipe(
                robots({
                    useragent: '*',
                    allow: ['/'],
                    disallow: ['cgi-bin/'],
                })
            )
            .pipe(gulp.dest('robots.txt'));
    });
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////
//////////////////////////////////////////////////
// SASS

function compliaSass() {
    return gulp
        .src('.core/scss/*.scss')
        .pipe(sass({ outputStyle: 'compressed' }))
        .pipe(
            autoprefixer({
                browsers: ['last 2 versions'],
                cascade: false,
            })
        )
        .pipe(minify())
        .pipe(gulp.dest('assets/css/'))
        .pipe(browserSync.stream());
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////
//////////////////////////////////////////////////
// JS Main

function gulpJS() {
    return gulp
        .src(['.core/js/*.js'])
        .pipe(concat('main.js'))
        .pipe(
            babel({
                presets: ['env'],
            })
        )
        .pipe(uglify())
        .pipe(gulp.dest('assets/js/'))
        .pipe(browserSync.stream());
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////
//////////////////////////////////////////////////
// SASS Plugins

function pluginsJs() {
    return gulp
        .src(['node_modules/jquery/dist/jquery.min.js'])
        .pipe(concat('plugins.js'))
        .pipe(gulp.dest('assets/js/'))
        .pipe(browserSync.stream());
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////
//////////////////////////////////////////////////
// Live Browser

function browser() {
    browserSync.init({
        server: {
            baseDir: './',
        },
    });
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////
//////////////////////////////////////////////////
// Minify images
function imageMin() {
    return gulp
        .src(['.core/images/*'])
        .pipe(
            imagemin([
                imagemin.gifsicle({ interlaced: true }),
                imagemin.mozjpeg({ quality: 20, progressive: true }),
                imagemin.optipng({ optimizationLevel: 5 }),
                imagemin.svgo({
                    plugins: [{ removeViewBox: true }, { cleanupIDs: false }],
                }),
            ])
        )
        .pipe(gulp.dest('assets/images/'));
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////
//////////////////////////////////////////////////
// Images WEBP

function webP() {
    return gulp
        .src(['.core/images/*'])
        .pipe(webp())
        .pipe(gulp.dest('assets/images/'));
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////
//////////////////////////////////////////////////
// AWS PUBLISHER

function deployAWS(files, target, header) {
    var publisher = awspublish.create({
        region: 'us-east-2',
        params: {
            Bucket: 'scompa-deploy',
        },
        credentials: {
            accessKeyId: 'AKIA4AWYGPOJZDXTKMHO',
            secretAccessKey: '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',
        },
    });

    return (
        gulp
            .src(files)
            .pipe(
                rename(function (path) {
                    path.dirname = target + path.dirname;
                })
            )
            .pipe(publisher.publish(header, { noAcl: true }))
            //.pipe(publisher.sync())
            .pipe(publisher.cache())
            .pipe(
                awspublish.reporter({
                    states: ['create', 'update', 'delete'],
                })
            )
    );
}

function sendFiles() {
    let stream = gulp.src(['.']);

    for (let i = 0, len = config.paths.length; i < len; i++) {
        let obj = config.paths[i];
        deployAWS(obj.filter, obj.target, obj.header);
    }
    return stream;
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////
//////////////////////////////////////////////////
// DEPLOY FTP

function deployFTP() {
    var conn = ftp.create({
        host: 'IP',
        user: 'USER',
        password: 'PASS',
        parallel: 10,
        log: gutil.log,
    });

    var globs = ['assets/**', 'index.html'];

    return gulp
        .src(globs, { base: '.', buffer: false })
        .pipe(conn.newer('.')) // only upload newer files
        .pipe(conn.dest('.'));
}

//////////////////////////////////////////////////
//////////////////////////////////////////////////
//////////////////////////////////////////////////
// Watch

function watch() {
    gulp.watch(['.core/scss/**/*'], compliaSass);
    gulp.watch(['.core/js/*.js'], gulpJS);
    gulp.watch(['.core/js/plugins/*.js'], pluginsJs);
    gulp.watch(['*.html']).on('change', browserSync.reload);
}

exports.compliaSass = compliaSass;
exports.gulpJS = gulpJS;
exports.pluginsJs = pluginsJs;
exports.browser = browser;
exports.watch = watch;
exports.imageMin = imageMin;
exports.webP = webP;
exports.generateRobots = generateRobots;
exports.deployAWS = deployAWS;
exports.sendFiles = sendFiles;
exports.deployFTP = deployFTP;

exports.default = gulp.parallel(
    watch,
    browser,
    compliaSass,
    gulpJS,
    pluginsJs,
    generateRobots
);
0

There are 0 answers