R
R
Rasul Gitinov2019-01-13 12:49:08
JavaScript
Rasul Gitinov, 2019-01-13 12:49:08

Why doesn't the dist folder appear in Gulp 4 after building the project?

Switched to Gulp 4 version and after executing the build task, the dist folder is not created.

// Build project

gulp.task('build', gulp.series('clean', gulp.parallel('nunjucks', 'sass', 'scripts', 'css-libs', 'img')), function() {
  var buildHtml = gulp.src([
    'app/*.html',
    'app/robots.txt'
  ])
  .pipe(gulp.dest('dist'));

  var buildCss = gulp.src([
    'app/css/styles.css',
    'app/css/libs.min.css'
    ])
  .pipe(gulp.dest('dist/css'))

  var buildJs = gulp.src([
    'app/js/common.js',
    'app/js/libs.min.js'
  ])
  .pipe(gulp.dest('dist/js'))

  var buildFonts = gulp.src('app/fonts/**/*')
  .pipe(gulp.dest('dist/fonts'))
});

How to solve this problem? In version 3 everything worked correctly.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey delphinpro, 2019-01-13
@raselgit

in general, the problem seems to be in the task() method.
Its signature has changed
task([taskName], taskFunction)
There is no third parameter here, as it was in the third version.
Accordingly declared anonymous functions are not run (this parameter is ignored) The
old approach to declaring tasks with pre-running of others does not work.
It is necessary to separately describe all tasks and run them through series/parallel, or anonymous functions in the same series
.

gulp.task(
  'sometask',      // название задачи
  ['anothertask'], // выполнить перед задачей
  function(){}     // сама задача
)

It became:
gulp.task(
  'sometask',     // название задачи
  gulp.series(    // последовательно выполнить
    'anothertask',  // другие задачи
     function(){}   // и саму задачу
  )
)

I'll add an incorrect option that can be misleading:
gulp.task(
  'sometask',     // название задачи
  gulp.series('anothertask'),  // выполнить другие задачи
  function(){}   // и саму задачу
)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question