Content deleted Content added
organisation changes |
|||
Line 38:
The gulp tasks are run from the [[Command-line interface|Command Line Interface (CLI)]]<ref>{{Cite web|url=https://github.com/gulpjs/gulp/blob/master/docs/CLI.md|title=gulpjs/gulp|website=GitHub|access-date=2016-09-23}}</ref> shell like Grunt and require package.json and gulpfile.js(simply gulpfile) in the project root directory. gulpfile is where all the plugins are loaded and the tasks are defined. First, all the necessary modules are loaded and then tasks are defined in the gulpfile. All the necessary plugins specified in the gulpfile are installed into the devDependencies<ref name=":2" />. The default task runs by <code>$gulp</code>. Individual tasks can be defined by gulp.task and are run by <code>gulp <task> <othertask></code><ref name=":1" />. Complex tasks are defined by chaining the plugins with the help of <code>.pipe()</code> operator<ref name=":3" />.
gulpfile is the place where all the operations are defined in gulp. The basic anatomy of the gulpfile consists of required plugins included at the top, definition of the tasks and a default task at the end.
Any installed plugin that is required to perform a task is to be added at the top of the gulpfile as a depedency in the following format. <syntaxhighlight lang="javascript">
//Adding dependencies
Line 48:
</syntaxhighlight>
The tasks can then be created. A gulp task is defined by ''gulp.task'' and takes the name of the task as the first parameter and a function as the second parameter.
Line 71:
</syntaxhighlight>
The default task is to be defined at the end of the gulpfile. It can be run by <code>gulp</code> command in the shell. In the case below, the default task does nothing.<ref name=":3" /> <syntaxhighlight lang ="javascript">
// Gulp default task
|