forked from 6101/6101
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·50 lines (39 loc) · 1.25 KB
/
gulpfile.js
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
var gulp = require('gulp'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
cssmin = require('gulp-minify-css'),
gulpif = require('gulp-if'),
connect = require('gulp-connect');
// mode=dev gulp
var env = process.env.mode;
gulp.task('server', function () {
if (env === 'deploy') return;
return connect.server({
port: 2222,
livereload: true
})
})
gulp.task('watch', ['css', 'js', 'concat'], function() {
if (env === 'deploy') return;
gulp.watch(['assets/mirror.css', 'assets/mirror.js', 'index.html'], ['reload'])
})
gulp.task('reload', ['css', 'js', 'concat'], function () {
return gulp.src(['index.html'])
.pipe(connect.reload())
})
gulp.task('concat', function() {
return gulp.src(['assets/zepto.js', 'assets/highlight.js', 'assets/marked.js'])
.pipe(concat('libs.js'))
.pipe(gulp.dest('dist/'))
})
gulp.task('css', function() {
return gulp.src(['assets/mirror.css'])
.pipe(gulpif(env === 'deploy', cssmin()))
.pipe(gulp.dest('dist/'))
})
gulp.task('js', function() {
return gulp.src(['assets/mirror.js'])
.pipe(gulpif(env === 'deploy', uglify()))
.pipe(gulp.dest('dist/'))
})
gulp.task('default', ['server', 'watch'])