Content deleted Content added
Add Template:Citation style, date=October 2016 |
Stevebroshar (talk | contribs) It's a build tool; not a framework |
||
(70 intermediate revisions by 49 users not shown) | |||
Line 1:
{{Short description|Server-side JavaScript build tool}}
{{How to|date=October 2016}}▼
{{lowercase title}}
{{multiple issues|
{{Infobox Software▼
{{context|date=January 2017}}
| logo = Gulp.js logo.png▼
| latest release version = 4.0.0▼
| category = [[Toolkit]]▼
| license = [[MIT License]]<ref>{{url|https://github.com/gulpjs/gulp/blob/master/LICENSE|title=License to github.com | language=en | access = 2016-05-30}}</ref>▼
}}
'''gulp.js''' is an [[Open-source software|open-source]], extensible, powerful and efficient [[JavaScript]] toolkit by Fractal Innovations<ref name=":0">{{Cite book|title=Developing a Gulp Edge|last=|first=|publisher=Bleeding Edge Press|year=2014|isbn=978-1-939902-14-6|edition=1st|___location=|pages=|via=|author = Jed Mao, Maximilian Schmitt, Tomasz Stryjewski, Cary Country Holt, William Lubelski}}</ref> and the open source community at [[git]], used as a streaming [[build system]] in [[front-end web development]].▼
| name = gulp
| logo caption =
| logo alt =
| logo size = 100px
| collapsible =
| screenshot = <!-- Image name is enough -->
| screenshot size =
| screenshot alt =
| caption =
| other_names =
▲
| developer = Blaine Bublitz, Eric Schoffstall
| released = {{Start date and age|2013|09|26|df=yes}}<ref>{{cite web | url=https://libraries.io/npm/gulp/versions | access-date=2020-12-31 | title=Release Date of Version 1.0.0}}</ref><!-- As per template guideline, this is the release date of version 1.0.0 -->
| ver layout =
| discontinued =
| latest_release_date = {{Start date and age|2024|03|29|df=yes}}<ref name="latest-releases">{{cite web | url=https://github.com/gulpjs/gulp/releases | access-date=2020-12-31 | title=Releases · gulpjs/gulp| website=[[GitHub]] }}</ref>
| latest preview version =
| latest preview date =
| repo = {{URL|https://github.com/gulpjs/gulp}}
| qid =
| programming language = [[JavaScript]] <!-- Node.js is NOT a language, it is a platform -->
| middleware =
| tools =
| engine =
| operating system = [[Linux]], [[macOS]], [[Windows]] <!-- As per template guideline, do not write "Cross-platform" here -->
| platform = [[Node.js]] <!-- As per template guideline, do not write "Cross-platform" here -->
| included with =
| replaces =
| replaced_by =
| service_name =
| size =
| standard =
| language =
| language count =
| language footnote =
▲| license = [[MIT License]]<ref>{{
| website =
| AsOf =
}}
'''gulp''' is an [[Open-source software|open-source]] [[JavaScript]] toolkit, used as a streaming [[build system]] (similar to a more package-focused [[Make (software)|Make]]) in [[front-end web development]].
It is a task runner built on [[Node.js]] and [[
gulp uses a code-over-configuration approach to define its tasks and relies on its small, single-
== Overview ==
gulp<ref>{{
== Need for a task runner ==
Even though
== Operation ==
The gulp tasks are run from
▲The gulp tasks are run from the [[Command-line interface|Command Line Interface (CLI)]]<ref name="gulpjs/gulp"/> 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">{{Cite web|url=https://docs.npmjs.com/cli/install|title=install {{!}} npm Documentation|website=docs.npmjs.com|access-date=2016-09-22}}</ref> 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">{{Cite web|url=https://github.com/gulpjs/gulp/blob/master/docs/getting-started.md|title=gulpjs/gulp|website=GitHub|access-date=2016-09-23}}</ref> Complex tasks are defined by chaining the plugins with the help of <code>.pipe()</code> operator.<ref name=":3" />
== Anatomy of gulpfile ==
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.<ref name="sitepoint.com">{{
=== Plugins ===
Any installed plugin that is required to perform a task is to be added at the top of the gulpfile as a
//Adding dependencies
var gulp = require (
var gutil = require ( 'util-gulp');▼
</syntaxhighlight>
Line 41 ⟶ 77:
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.
The following example shows the creation of a gulp tasks. The first parameter ''
//do something▼
▲gulp.task ( 'taskName', function () {
▲//do something
});
</syntaxhighlight>
Line 50 ⟶ 85:
Alternatively, a task that performs several predefined functions can be created. Those functions are passed as the second parameter in the form of an array. <syntaxhighlight lang="javascript">
function fn1 () {
// do something
}
function fn2 () {
//
}
// Task with array of function names
gulp.task
</syntaxhighlight>
=== Default task ===
The default task is to be defined at the end of the gulpfile. It can be run by the <code>gulp</code> command in the shell. In the case below, the default task does nothing.<ref name=":3" /> <syntaxhighlight lang
// Gulp default task
gulp.task
</syntaxhighlight>The default task is used in gulp to run any number of dependent sub tasks defined above in a sequential order automatically. gulp can also monitor source files and run an appropriate task when changes are made to the files. The sub tasks are to be mentioned as the elements of the array in the second parameter. The process can be triggered by simply running the default task by <code>gulp</code> command.<ref name="sitepoint.com"/>
Line 71 ⟶ 106:
=== Image Task ===
▲Subsequently, the module must be at the beginning of '' gulpfile 'defined' as: ''<syntaxhighlight lang= "javascript">
</syntaxhighlight>
The subsequent image task optimizes images. <Code>
// Images task
gulp.task
return gulp.src
.pipe
.pipe
});
Line 90 ⟶ 123:
=== Scripts Task ===
In the following example, all JavaScript files from the directory ''
// Script task
gulp.task
return gulp.src
.pipe
.pipe
});
</syntaxhighlight>
=== Watch Task ===
The Watch-task serves to react to changes in files. In the following example, the tasks with the names ''scripts
// Rerun the task When a file changes
gulp.task
gulp.watch
gulp.watch
cb();
});
</syntaxhighlight>
Furthermore, it is possible to accomplish an update of the browser content using the Watch-tasks.<ref>{{
==See also==
* [[Grunt (software)]]
* [[Browserify]]
==
{{
==
*{{Cite book|title=Developing a Gulp Edge
*{{Cite book| author=Den Odell | title=Pro JavaScript Development Coding, Capabilities, and Tooling | publisher=Apress |year=2014 |chapter=Build Tools and Automation |isbn=978-1-4302-6268-8}}
*{{Cite book|title=Getting Started with Gulp|last=Maynard|first=Travis|publisher=Packt Publishing Ltd|year=2015|isbn=9781784393472
== External links ==
* {{Official website}}
* {{GitHub|gulpjs/gulp|
[[Category:JavaScript programming tools]]
|