Content deleted Content added
m →top: Update version |
Stevebroshar (talk | contribs) It's a build tool; not a framework |
||
(44 intermediate revisions by 30 users not shown) | |||
Line 1:
{{Short description|Server-side JavaScript build tool}}
{{lowercase title}}
{{multiple issues|
{{How
{{context|date=January 2017}}
}}
{{Infobox
|
| logo = Gulp.js Logo.svg
| logo caption =
| latest release version = 4.0.0▼
| logo alt =
| latest_release_date = {{Start date and age|2017|12|31|df=yes}}<ref name="previous-releases">{{cite web | url=https://github.com/gulpjs/gulp/blob/master/CHANGELOG.md | accessdate=2017-12-131 | title=gulp changelog}}</ref>▼
| logo size = 100px
| collapsible =
| genre = [[Toolkit]]▼
| screenshot = <!-- Image name is enough -->
| screenshot size =
| license = [[MIT License]]<ref>{{cite web|url=https://github.com/gulpjs/gulp/blob/master/LICENSE|title=License to github.com | language=en | accessdate = 2016-05-30}}</ref>▼
| screenshot alt =
| caption =
'''gulp.js''' is an [[Open-source software|open-source]] [[JavaScript]] toolkit by Fractal Innovations<ref name=":0">{{Cite book|title=Developing a Gulp Edge|publisher=Bleeding Edge Press|year=2014|isbn=978-1-939902-14-6|edition=1st|___location=|pages=|via=|author1=Jed Mao |author2=Maximilian Schmitt |author3=Tomasz Stryjewski |author4=Cary Country Holt |author5=William Lubelski }}</ref> and the open source community at [[GitHub]], used as a streaming [[build system]] in [[front-end web development]].▼
| 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|
| 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 =
▲| genre = [[Toolkit]]
▲| license = [[MIT License]]<ref>{{cite web | url=https://github.com/gulpjs/gulp/blob/master/LICENSE | title=
| 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 [[npm (software)|npm]], used for automation of time-consuming and repetitive tasks involved in web development like [[Minification (programming)|minification]], concatenation, cache busting, [[unit testing]], [[Linting software|linting]], optimization, etc.<ref>{{cite web|url=https://www.smashingmagazine.com/2014/06/building-with-gulp/ |title=Building With Gulp – Smashing Magazine |website=Smashingmagazine.com |date=11 June 2014 |
gulp uses a code-over-configuration approach to define its tasks and relies on its small, single-
== Overview ==
gulp<ref>{{cite web|url=https://github.com/gulpjs/gulp/blob/master/docs/FAQ.md|title=gulpjs/gulp|website=GitHub|access-date=2016-09-22}}</ref> is a build tool in JavaScript built on [[node stream]]s. These streams facilitate the connection of file operations through [[Pipeline (software)|pipelines]].<ref name="github.com">{{cite web|url=https://github.com/substack/stream-handbook |title=substack/stream-handbook: how to write node programs with streams |publisher=GitHub |access-date
== Need for a task runner ==
Task-runners like gulp and [[Grunt (software)|
Even though some developers prefer [[Node Package Manager|npm]] scripts because they can be simple and easy to implement, there are numerous ways where gulp and
== Operation ==
The gulp tasks are run from a [[
== Anatomy of gulpfile ==
Line 35 ⟶ 71:
Any installed plugin that is required to perform a task is to be added at the top of the gulpfile as a dependency in the following format.<ref name=":1" /><ref name=":3" /> <syntaxhighlight lang="javascript">
//Adding dependencies
var gulp = require (
var gutil = require ( 'util-gulp');▼
</syntaxhighlight>
Line 42 ⟶ 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 51 ⟶ 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 72 ⟶ 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 91 ⟶ 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>{{cite web|url=https://www.browsersync.io/docs/gulp/ |title=Browsersync + Gulp.js |website=Browsersync.io |access-date
==See also==
* [[Grunt (software)]]
* [[Browserify]]
==References==
Line 116 ⟶ 153:
==Literature==
*{{Cite book|title=Developing a Gulp Edge|publisher=Bleeding Edge Press|year=2014|isbn=978-1-939902-14-6|edition=1st
*{{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]]
|