-
Notifications
You must be signed in to change notification settings - Fork 1
/
learn-gulp.html
294 lines (251 loc) · 7.86 KB
/
learn-gulp.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
<!doctype html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
<meta charset="utf-8">
<title>Learn Gulp</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="css/reveal.min.css">
<link rel="stylesheet" href="css/theme/night.css" id="theme">
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- If the query includes 'print-pdf', include the PDF print sheet -->
<script>
if( window.location.search.match( /print-pdf/gi ) ) {
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'css/print/pdf.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
}
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
<style>
.authorArea {
margin-top: 100px !important;
text-align: right;
font-size: 90% !important;
}
.code {
}
section {
text-align: left;
}
pre {
margin: 0px !important;
font-size: 105% !important;
}
code {
font-family: monospace !important;
}
small {
font-size: .8em !important;
margin: 10px 0px !important;
}
ul {
margin: 10px 0px !important;
list-style: none !important;
}
</style>
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<h2>Learn Gulp</h2>
</section>
<section>
<h2>自我介绍</h2>
<div class="authorArea">
<p>郑豪举, 数云前端工程师, 网名 Hurry</p>
<p>github: <a href="https://github.com/hjzheng">https://github.com/hjzheng</a></p>
</div>
</section>
<section>
<h2>什么是 Gulp ?</h2>
<h3>The streaming build system</h3>
<img src="img/gulp1.png" height="232" width="216">
</section>
<section>
<h2>Streams</h2>
<p class="fragment">
"We should have some ways of connecting programs like garden hose--screw in
another segment when it becomes necessary to massage data in
another way. This is the way of IO also."
</p>
<p class="fragment"> -- Doug McIlroy. October 11, 1964</p>
</section>
<section>
<section>
<h2>为什么使用 Streams</h2>
<ul class="fragment">
<li>性能好</li>
<li>简单易用</li>
</ul>
</section>
<section>
<h3>copy文件,并将文件中小写字母转成大写</h3>
<pre><code data-trim contenteditable>
//Stream Way
var fs = require('fs');
var through = require('through2');
var stream = through(write, end);
function write(buffer, encoding, next){
this.push(buffer.toString().toUpperCase());
next();
}
function end(done){
done();
}
function copy(src, target) {
fs.createReadStream(src).pipe(stream).pipe(fs.createWriteStream(target));
}
console.time('stream way');
copy('./test.txt', './test2.txt');
console.timeEnd('stream way');
</code></pre>
</section>
<section>
<pre><code data-trim contenteditable>
//Normal Way
var fs = require('fs');
function copy(src, target) {
var content = fs.readFileSync(src).toString().toUpperCase();
fs.writeFileSync(target, content);
}
console.time('normal way');
copy('./test.txt', './test1.txt');
console.timeEnd('normal way');
</code></pre>
</section>
</section>
<section>
<section>
<h3>Gulp has only 5 functions you need to learn </h3>
</section>
<section>
<h2>gulp.task(name, fn)</h2>
<small>定义task</small>
<pre><code data-trim contenteditable>
var gulp = require('gulp');
gulp.task('test', function() {
console.log('hello test!')
});
</code></pre>
</section>
<section>
<h2>gulp.run(tasks...)</h2>
<small>运行task</small>
<pre><code data-trim contenteditable>
gulp.run(["miniCSS"]);
</code></pre>
</section>
<section>
<h2>gulp.watch(glob, fn)</h2>
<small>监控变化</small>
<pre><code data-trim contenteditable>
gulp.watch(['./**/*.css'], ['miniCSS']);
</code></pre>
</section>
<section>
<h2>gulp.src(glob)</h2>
<small>输入</small>
<pre><code data-trim contenteditable>
var gulp = require('gulp');
var uglify = require('gulp-uglify');
gulp.task('default', function() {
gulp.src('src/*.js')
.pipe(uglify()) //压缩js
.pipe(gulp.dest('dist'))
});
</code></pre>
</section>
<section>
<h2>gulp.dest(folder)</h2>
<small>输出</small>
<pre><code data-trim contenteditable>
var gulp = require('gulp');
var uglify = require('gulp-uglify');
gulp.task('default', function() {
gulp.src('src/*.js')
.pipe(uglify()) //压缩js
.pipe(gulp.dest('dist'))
});
</code></pre>
</section>
<section>
<h2>恭喜,你已经是gulp专家了!!!</h2>
</section>
</section>
<section>
<section>
<h2>Gulp可以帮我们做什么</h2>
<ul class="fragment">
<li>Minification</li>
<li>Concat</li>
<li>Sass to CSS</li>
<li>Injecting files into html</li>
<li>Code analysis</li>
<li>Caching Angular templates</li>
<li>Transpiler</li>
<li>Testing</li>
<li>Sync Code</li>
</ul>
</section>
<section>
<img src="img/gulp2.png" height="600" width="1000">
</section>
</section>
<section>
<section>
<h2>Gulp VS Grunt</h2>
</section>
<section>
<img src="img/gulp4.png" height="500" width="1000">
</section>
<section>
<img src="img/gulp5.png" height="542" width="1000">
</section>
<section>
<img src="img/gulp3.png" height="512" width="1000">
</section>
</section>
<section>
<h2><a href="https://github.com/Platform-CUF/use-gulp">关于 Gulp 更多内容</a></h2>
</section>
<section>
<section>
<h2>Q&A</h2>
</section>
</section>
<section>
<section>
<h2>谢谢观赏</h2>
<div class="authorArea">
<p>2016-1-27</p>
<p>如果你喜欢,请<a href="https://github.com/hjzheng/CUF_PPTs">star</a>我</p>
</div>
</section>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.min.js"></script>
<script>
Reveal.initialize({
history: true,
transition: 'linear',
progress: true,
math: {
// mathjax: 'http://cdn.mathjax.org/mathjax/latest/MathJax.js',
config: 'TeX-AMS_HTML-full'
},
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }
]
});
</script>
</body>
</html>