1 | <p align="center">
|
2 | <a href="http://gulpjs.com">
|
3 | <img height="257" width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png">
|
4 | </a>
|
5 | </p>
|
6 |
|
7 | # gulp
|
8 | **The streaming build system**
|
9 |
|
10 | [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Support us][gittip-image]][gittip-url] [![Build Status][travis-image]][travis-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url]
|
11 |
|
12 | ## Like what we do?
|
13 |
|
14 | [Support us via Gratipay](https://gratipay.com/WeAreFractal/)
|
15 |
|
16 | ## Documentation
|
17 |
|
18 | For a Getting started guide, API docs, recipes, making a plugin, etc. see the [documentation page](/docs/README.md)!
|
19 |
|
20 | ## Sample `gulpfile.js`
|
21 |
|
22 | This file is just a quick sample to give you a taste of what gulp does.
|
23 |
|
24 | ```js
|
25 | var gulp = require('gulp');
|
26 | var coffee = require('gulp-coffee');
|
27 | var concat = require('gulp-concat');
|
28 | var uglify = require('gulp-uglify');
|
29 | var imagemin = require('gulp-imagemin');
|
30 | var sourcemaps = require('gulp-sourcemaps');
|
31 | var del = require('del');
|
32 |
|
33 | var paths = {
|
34 | scripts: ['client/js/**/*.coffee', '!client/external/**/*.coffee'],
|
35 | images: 'client/img/**/*'
|
36 | };
|
37 |
|
38 | // Not all tasks need to use streams
|
39 | // A gulpfile is just another node program and you can use all packages available on npm
|
40 | gulp.task('clean', function(cb) {
|
41 | // You can use multiple globbing patterns as you would with `gulp.src`
|
42 | del(['build'], cb);
|
43 | });
|
44 |
|
45 | gulp.task('scripts', ['clean'], function() {
|
46 | // Minify and copy all JavaScript (except vendor scripts)
|
47 | // with sourcemaps all the way down
|
48 | return gulp.src(paths.scripts)
|
49 | .pipe(sourcemaps.init())
|
50 | .pipe(coffee())
|
51 | .pipe(uglify())
|
52 | .pipe(concat('all.min.js'))
|
53 | .pipe(sourcemaps.write())
|
54 | .pipe(gulp.dest('build/js'));
|
55 | });
|
56 |
|
57 | // Copy all static images
|
58 | gulp.task('images', ['clean'], function() {
|
59 | return gulp.src(paths.images)
|
60 | // Pass in options to the task
|
61 | .pipe(imagemin({optimizationLevel: 5}))
|
62 | .pipe(gulp.dest('build/img'));
|
63 | });
|
64 |
|
65 | // Rerun the task when a file changes
|
66 | gulp.task('watch', function() {
|
67 | gulp.watch(paths.scripts, ['scripts']);
|
68 | gulp.watch(paths.images, ['images']);
|
69 | });
|
70 |
|
71 | // The default task (called when you run `gulp` from cli)
|
72 | gulp.task('default', ['watch', 'scripts', 'images']);
|
73 | ```
|
74 |
|
75 | ## Incremental Builds
|
76 |
|
77 | We recommend these plugins:
|
78 |
|
79 | - [gulp-changed](https://github.com/sindresorhus/gulp-changed) - only pass through changed files
|
80 | - [gulp-cached](https://github.com/wearefractal/gulp-cached) - in-memory file cache, not for operation on sets of files
|
81 | - [gulp-remember](https://github.com/ahaurw01/gulp-remember) - pairs nicely with gulp-cached
|
82 | - [gulp-newer](https://github.com/tschaub/gulp-newer) - pass through newer source files only, supports many:1 source:dest
|
83 |
|
84 | ## Want to contribute?
|
85 |
|
86 | Anyone can help make this project better - check out the [Contributing guide](/CONTRIBUTING.md)!
|
87 |
|
88 |
|
89 | [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/wearefractal/gulp/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
|
90 |
|
91 | [gittip-url]: https://www.gittip.com/WeAreFractal/
|
92 | [gittip-image]: http://img.shields.io/gittip/WeAreFractal.svg
|
93 |
|
94 | [downloads-image]: http://img.shields.io/npm/dm/gulp.svg
|
95 | [npm-url]: https://npmjs.org/package/gulp
|
96 | [npm-image]: http://img.shields.io/npm/v/gulp.svg
|
97 |
|
98 | [travis-url]: https://travis-ci.org/gulpjs/gulp
|
99 | [travis-image]: http://img.shields.io/travis/gulpjs/gulp.svg
|
100 |
|
101 | [coveralls-url]: https://coveralls.io/r/gulpjs/gulp
|
102 | [coveralls-image]: http://img.shields.io/coveralls/gulpjs/gulp/master.svg
|
103 |
|
104 | [gitter-url]: https://gitter.im/gulpjs/gulp
|
105 | [gitter-image]: https://badges.gitter.im/gulpjs/gulp.png
|