add.js
function defineTasksForConfig(taskData) {
  // Define gulp tasks (build and optionally watch)
  // For the task name:
  // - single config, no 'name' key: <callback>
  // - single config, 'name' key: <callback>_<name>
  // - multiple configs, no 'name' key: <callback>_<index>
  const { callback, name, normalizedConfigs } = taskData
  normalizedConfigs.forEach((config, index) => {
    let taskId = name
    if (typeof config.name === 'string') {
      taskId += `_${config.name.trim()}`
    } else if (normalizedConfigs.length > 1) {
      taskId += `_${index + 1}`
    }
    const buildId = options.buildPrefix + taskId
    const watchId = options.watchPrefix + taskId

    // Register build task
    gulp.task(buildId, done => {
      return callback(config, {
        done: done,
        catchErrors: catchErrors,
        showError: showError,
        showSizes: showSizes,
        simpleStream: simpleStream
      })
    })

    // Register matching watch task
    if (Array.isArray(config.watch) && config.watch.length > 0) {
      gulp.task(watchId, () => {
        return gulp.watch(config.watch, gulp.series(buildId))
      })
    }
  })
}
function defineTasksForConfig(taskData) {
  // Define gulp tasks (build and optionally watch)
  // For the task name:
  // - single config, no 'name' key: <callback>
  // - single config, 'name' key: <callback>_<name>
  // - multiple configs, no 'name' key: <callback>_<index>
  const { callback, name, normalizedConfigs } = taskData
  normalizedConfigs.forEach((config, index) => {
    let taskId = name
    if (typeof config.name === 'string') {
      taskId += `_${config.name.trim()}`
    } else if (normalizedConfigs.length > 1) {
      taskId += `_${index + 1}`
    }
    const buildId = options.buildPrefix + taskId
    const watchId = options.watchPrefix + taskId

    // Register build task
    gulp.task(buildId, done => {
      return callback(config, {
        done: done,
        catchErrors: catchErrors,
        showError: showError,
        showSizes: showSizes,
        simpleStream: simpleStream
      })
    })

    // Register matching watch task
    if (Array.isArray(config.watch) && config.watch.length > 0) {
      gulp.task(watchId, () => {
        return gulp.watch(config.watch, gulp.series(buildId))
      })
    }
  })
}
function defineTasksForConfig ( taskData ) { // Define gulp tasks (build and optionally watch) // For the task name: // - single config, no 'name' key: <callback> // - single config, 'name' key: <callback>_<name> // - multiple configs, no 'name' key: <callback>_<index> const { callback , name , normalizedConfigs } = taskData normalizedConfigs . forEach ( ( config , index ) => { let taskId = name if ( typeof config . name === 'string' ) { taskId += ` ${ config . name . trim ( ) } ` } else if ( normalizedConfigs . length > 1 ) { taskId += ` ${ index + 1 } ` } const buildId = options . buildPrefix + taskId const watchId = options . watchPrefix + taskId // Register build task gulp . task ( buildId , done => { return callback ( config , { done : done , catchErrors : catchErrors , showError : showError , showSizes : showSizes , simpleStream : simpleStream } ) } ) // Register matching watch task if ( Array . isArray ( config . watch ) && config . watch . length > 0 ) { gulp . task ( watchId , ( ) => { return gulp . watch ( config . watch , gulp . series ( buildId ) ) } ) } } ) }
Register matching 'build' and 'watch' gulp tasks
@param {object} taskData
Register matching build and watch gulp tasks