最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - What does it means call a task with a colon in gulp? - Stack Overflow

programmeradmin6浏览0评论

I would like to know what is the use of : colon when used as follow in a gulp task.

  • Does it pass a parameters?

gulp.task('default', ['clean:mobile']);

I would like to know what is the use of : colon when used as follow in a gulp task.

  • Does it pass a parameters?

gulp.task('default', ['clean:mobile']);
Share Improve this question edited Sep 15, 2017 at 18:50 GibboK asked Dec 18, 2015 at 10:19 GibboKGibboK 73.9k147 gold badges451 silver badges672 bronze badges 1
  • 2 AFAIK it is just a simple way to namespace your tasks in a readable way. In your example the clean:mobile task will perform a clean task specifically to the mobile assets I guess. – MarcoL Commented Dec 18, 2015 at 10:51
Add a ment  | 

1 Answer 1

Reset to default 20

Gulp does not give a special meaning to the colon. In projects where it has a special meaning, the meaning es from somewhere else than Gulp: project culture or history, other tools, etc.

Some people use it as a way to organize their task names. All tasks that have to do with cleanup could start with clean:. So you'd have clean:dist, clean:build, etc. (If you wonder why the multiple targets for cleaning, some people like to have multiple degrees of cleaning. clean:build would remove transpiled files but would leave some local configuration files alone. clean:dist would remove all files that are not part of the source distribution (i.e. remove more).)

Some people will use hyphens for the same goal, or some other character. Gulp-tools like this one may interpret the colon as an organization device. Note that this tool also interprets the underscore (_) and the hyphen (-) in the same as it interprets the colon.

The colon is meaningful in Grunt. People who convert a build system from Grunt to Gulp may keep the colons because their original tasks in Grunt had colons in them. If you have a team used to the task names originally created in Grunt, or interface with other tools that call these tasks, it may be advantageous to just keep the colons instead of having to ask people to adapt or have to update code that calls build tasks.

发布评论

评论列表(0)

  1. 暂无评论