V
V
Vladimir2021-03-09 00:57:33
gulp.js
Vladimir, 2021-03-09 00:57:33

Error while running gulp. How to fix?

Hello, can you tell me what is wrong?
Here is the gulp file code:

let preprocessor = 'sass';

const {app, dest, parallel, watch} = require('gulp'),
      browserSync = require('browser-sync').create(),
      concat = require('gulp-concat'),
      uglify = require('gulp-uglify-es').default(),
      sass = require('gulp-sass'),
      autoprefixer = require('gulp-autoprefixer'),
      cleancss = require('gulp-clean-css'),
      imagemin = require('gulp-imagemin'),
      newer = require('gulp-newer'),
      del = require('del');


function browsersync() {
    browserSync.init({
        server: {'baseDir': 'src/'},
        notify: false,
        online: true
    });
}

function scripts() {
  return app([ 
    'src/js/script.js'
    ])
  .pipe(concat('script.min.js')) 
  .pipe(uglify()) 
  .pipe(dest('src/js/')) 
  .pipe(browserSync.stream());
}

function startwatch() {
  watch(['src/**/*.js', '!src/**/*.min.js'], scripts);
    watch('src/**/' + preprocessor + '/**/*', styles);
    watch('src/**/*.html').on('change', browserSync.reload);
    watch('src/images/**/*', images);
}

function styles() {
  return app('src/' + preprocessor + '/style.' + preprocessor + '')
  .pipe(eval(preprocessor)()) 
  .pipe(concat('style.min.css'))
  .pipe(autoprefixer({ overrideBrowserslist: ['last 10 versions'], grid: true })) 
  .pipe(cleancss( { level: { 1: { specialComments: 0 } }} ))
  .pipe(dest('src/css/'))
  .pipe(browserSync.stream());
}

function images() {
  return app('src/images/**/*') 
  .pipe(newer('src/images')) 
  .pipe(imagemin()) 
  .pipe(dest('src/images'));
}

function cleanimg() {
  return del('src/images/**/*', { force: true });
}

exports.browsersync = browsersync;
exports.scripts = scripts;
exports.styles = styles;
exports.images = images;
exports.cleanimg = cleanimg;
exports.default = parallel(styles, scripts, browsersync, startwatch);


The error is here:

60469d8b80192504829258.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
inkShio, 2021-03-09
@inkShio

require('gulp-uglify-es').default;

V
Vladimir, 2021-03-09
@onlyJavaScriptProgrammer

Fixed it, but the problem is still the same. I don't understand why app is not a function...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question