-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
132 lines (116 loc) · 3.26 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
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
/**
* @author Milad Naseri ([email protected])
* @since 1.0 (4/9/16)
*/
//Gulp main
var gulp = require("gulp");
var uglify = require("gulp-uglify");
var del = require("del");
var copy = require("gulp-copy");
var concat = require("gulp-concat");
var wiredep = require("gulp-wiredep");
var sourcemaps = require('gulp-sourcemaps');
var git = require('gulp-git');
var sass = require('gulp-sass');
var refresh = require('gulp-refresh');
var markedown = require('gulp-markdown');
var highlight = require('gulp-highlight');
//configs
var paths = {
main: "src/index.html",
scripts: [
'src/js/*.js',
'src/js/**/*.js'
],
styles: [
'src/scss/*.scss'
],
parts: [
'src/scss/**/*.scss'
],
lib: [
"src/lib/**/*.min.js",
"src/lib/**/*.min.css"
],
views: [
"src/views/*.md",
"src/views/*.html"
],
site: {
root: "site",
scripts: "site/js",
styles: "site/css",
lib: "site/lib",
views: "site/views"
}
};
gulp.task('clean', function (done) {
del([paths.site.root], done);
});
gulp.task("lib", function () {
return gulp.src(paths.lib)
.pipe(copy(paths.site.lib, {prefix: 2}))
.pipe(refresh())
});
gulp.task("scripts", function () {
return gulp.src(paths.scripts)
.pipe(concat('all.min.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest(paths.site.scripts))
.pipe(refresh())
});
gulp.task("index", function () {
return gulp.src(paths.main)
.pipe(wiredep({
fileTypes: {
html: {
replace: {
js: function (path) {
path = path.replace(/\.js$/, '.min.js').replace(/(\.min)+.js/, '.min.js');
return "<script type='application/javascript' src='" + path + "'></script>";
}
}
}
},
overrides: {
'angular-ui': {
main: ['/build/angular-ui.min.js', '/build/angular-ui.min.css']
}
}
}))
.pipe(gulp.dest(paths.site.root))
.pipe(refresh())
});
gulp.task('sass', function () {
return gulp.src(paths.styles)
.pipe(sourcemaps.init())
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
.pipe(sourcemaps.write())
.pipe(gulp.dest(paths.site.styles))
.pipe(refresh())
});
gulp.task('git-site', function () {
return gulp.src(paths.site.root)
.pipe(git.add());
});
gulp.task('watch', function () {
refresh.listen({
port: 13001
});
gulp.watch(paths.site.root, ['git-site']);
gulp.watch(paths.parts, ['sass']);
gulp.watch(paths.scripts, ['scripts']);
gulp.watch(paths.lib, ['lib']);
gulp.watch(paths.main, ['index']);
gulp.watch(paths.views, ['views']);
});
gulp.task("views", function () {
return gulp.src(paths.views)
.pipe(markedown())
.pipe(highlight())
.pipe(gulp.dest(paths.site.views))
.pipe(refresh())
});
gulp.task("default", ["generate", "watch"]);
gulp.task("generate", ["lib", "scripts", "sass", "views", "index", "git-site"]);
gulp.task("regenerate", ["clean", "generate"]);