Content deleted Content added
Fix code formatting + update plugin count |
Stevebroshar (talk | contribs) It's a build tool; not a framework |
||
(25 intermediate revisions by 20 users not shown) | |||
Line 1:
{{Short description|Server-side JavaScript build tool}}
{{lowercase title}}
{{multiple issues|
{{How
{{context|date=January 2017}}
}}
{{Infobox
|
| logo
|
| logo alt =
| latest release version = 4.0.0▼
| logo size = 100px
| 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=2018-01-11 | title=gulp changelog}}</ref>▼
| collapsible =
| screenshot = <!-- Image name is enough -->
| genre = [[Toolkit]]▼
|
| screenshot alt =
| 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>▼
| 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|
| 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-purpose plugins to carry them out. The gulp ecosystem includes more than 3500 such plugins.<ref>{{cite web|url=https://gulpjs.com/plugins/ |title=gulp.js plugin registry |website=Gulpjs.com |access-date
== 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)|Grunt]] are built on Node.js rather than [[Node Package Manager|npm]]
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 Grunt seem to have an advantage over each other, and the default provided scripts.<ref name="gulpjs/gulp">{{cite web|url=https://github.com/gulpjs/gulp/blob/master/docs/CLI.md|title=gulpjs/gulp|website=GitHub|access-date=2016-09-23}}</ref>
== Operation ==
The gulp tasks are run from a [[command-line interface]] (CLI)<ref name="gulpjs/gulp"/> shell and require two files, <code>package.json</code>, which is used to list the various plugins for gulp, and <code>gulpfile.js</code> (or simply <code>gulpfile</code>), These, as per build tool convention, are often found in the
== Anatomy of gulpfile ==
Line 43 ⟶ 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 ''
gulp.task('taskName', function () {
//do something
Line 76 ⟶ 110:
</syntaxhighlight>
The subsequent image task optimizes images. <Code>gulp.src()</code> retrieves all the images with the extension .png, .gif or .jpg in the directory ''
<Code>.pipe(imagemin())</Code> channels the images found, through the optimization process and with <code>.pipe(gulp.dest())</code> the optimized images are saved to the ''
// Images task
gulp.task('images', function () {
Line 89 ⟶ 123:
=== Scripts Task ===
In the following example, all JavaScript files from the directory ''
// Script task
gulp.task('scripts', function () {
Line 99 ⟶ 133:
=== 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('watch', function (cb) {
Line 109 ⟶ 143:
</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 115 ⟶ 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 ==
|