-
Notifications
You must be signed in to change notification settings - Fork 15
/
gulpfile.js
97 lines (84 loc) · 2.47 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
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
var gulp = require('gulp'),
concat = require('gulp-concat'),
subtree = require('gulp-subtree'),
clean = require('gulp-clean'),
rename = require('gulp-rename'),
runSequence = require('run-sequence'),
minifycss = require('gulp-minify-css'),
uglify = require('gulp-uglify'),
streamify = require('gulp-streamify');
// Directories
var SRC = './src/',
BUILD = './build/',
DIST = './dist/',
BOWER = './bower_components/';
gulp.task('dist-clean', function() {
return gulp.src(DIST).pipe(clean());
})
gulp.task('copyFiles', function() {
return gulp.src([
SRC + '**/*.css',
SRC + '**/*.js',
SRC + 'index.html',
])
.pipe(gulp.dest(DIST));
});
gulp.task('packagecss', function() {
return gulp.src([
BOWER + 'codemirror/lib/codemirror.css',
SRC + 'css/mirrormark.css'
])
.pipe(concat('mirrormark.package.css'))
.pipe(gulp.dest(DIST + 'css'));
});
gulp.task('packagejs', function() {
return gulp.src([
BOWER + 'codemirror/lib/codemirror.js',
BOWER + 'codemirror/mode/markdown/markdown.js',
BOWER + 'codemirror/mode/edit/continuelist.js',
BOWER + 'lodash/lodash.js',
SRC + 'js/mirrormark.js'
])
.pipe(concat('mirrormark.package.js'))
.pipe(gulp.dest(DIST + 'js'));
});
gulp.task('minifycss', function() {
return gulp.src([
DIST + 'css/demo.css',
DIST + 'css/codemirror.css',
DIST + 'css/mirrormark.css',
DIST + 'css/mirrormark.package.css'
])
.pipe(minifycss())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest(DIST + 'css'));
});
gulp.task('minifyjs', function() {
return gulp.src(DIST + 'js/*.js')
.pipe(streamify(uglify()))
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest(DIST + 'js'));
});
/**
* Master Tasks
**/
gulp.task('build', function(callback) {
// runSequence runs tasks in sequence to keep things straight forward
return runSequence('dist-clean', 'copyFiles', ['packagecss', 'packagejs'], ['minifycss', 'minifyjs'], callback);
});
// Just build it
gulp.task('default', ['build']);
// Deploy to GH pages
gulp.task('temp', ['build'], function() {
return gulp.src(DIST + '/**/*')
.pipe(gulp.dest(BUILD));
});
gulp.task('deploy', ['temp'], function() {
return gulp.src(BUILD)
.pipe(subtree())
.pipe(clean());
});