javascript Gulpfile De任务Sequenciais

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript Gulpfile De任务Sequenciais相关的知识,希望对你有一定的参考价值。

'use strict';

const gulp = require('gulp');
const del = require('del');
const gulpRequireTasks = require('gulp-require-tasks');
const paths = require('./config/paths');
const env = process.env.NODE_ENV;
const envTaskPath = env === 'production' ? '/prod' : '/dev';

gulpRequireTasks({
	path: __dirname + '/gulp-tasks'
});

gulpRequireTasks({
	path: `${__dirname}/gulp-tasks/${envTaskPath}`
});

function runSequential(tasks) {
	if (!tasks || tasks.length <= 0) {
		return;
	}
	const task = tasks[0];
	gulp.start(task, () => {
		console.log(`${task} finished`);
		runSequential(tasks.slice(1));
	});
}

gulp.task('clean', () => {
	return del([
		paths.dest.css,
		paths.dest.fonts,
		paths.dest.img,
		paths.dest.js,
		paths.dest.templates,
		`${paths.destinationPath}/ps-bootstrap`,
		`${paths.destinationPath}/ps-website-assets`
	], {
		force: true
	});
});

gulp.task('default', () => runSequential(Object.keys(gulp.tasks).filter((taskName) => taskName.startsWith('build-'))));


// 2 VERSÃO

  gulp.task( 'task1', () => console.log(a) )
  gulp.task( 'task2', () => console.log(a) )
  gulp.task( 'task3', () => console.log(a) )
  gulp.task( 'task4', () => console.log(a) )
  gulp.task( 'task5', () => console.log(a) )

  function runSequential( tasks ) {
    if( !tasks || tasks.length <= 0 ) return;

    const task = tasks[0];
    gulp.start( task, () => {
        console.log( `${task} finished` );
        runSequential( tasks.slice(1) );
    } );
  }
  gulp.task( "run-all", () => runSequential([ "task1", "task2", "task3", "task4", "task5" ));
  

以上是关于javascript Gulpfile De任务Sequenciais的主要内容,如果未能解决你的问题,请参考以下文章

javascript Gulp 4 - 具有外部配置的多文件任务。使用gulp-load-plugins的基本gulpfile模板,用于多个任务文件

Javascript:在 gulpfile.js 中获取 package.json 数据

Javascript:在gulpfile.js中获取package.json数据

任务“默认”不在您的 gulpfile 中

任务'sass'不在你的gulpfile中

使用 npm 链接时如何修复“任务不在您的 gulpfile 中”错误?