This repository has been archived by the owner on Oct 22, 2021. It is now read-only.
forked from newgene/caffeine-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
117 lines (106 loc) · 3.72 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
"use strict";
var PORT, _s, addsrc, banner, browserSync, changed, concat, cssmin, dist, gulp, gutil, header, pkg, prefix, reload, sass, src, strip, uglify;
gulp = require("gulp");
gutil = require("gulp-util");
sass = require("gulp-sass");
concat = require("gulp-concat");
header = require("gulp-header");
uglify = require("gulp-uglify");
cssmin = require("gulp-cssmin");
addsrc = require("gulp-add-src");
changed = require("gulp-changed");
pkg = require("./package.json");
_s = require("underscore.string");
prefix = require("gulp-autoprefixer");
strip = require("gulp-strip-css-comments");
browserSync = require("browser-sync");
reload = browserSync.reload;
PORT = {
GHOST: 2368,
BROWSERSYNC: 3000
};
dist = {
name: _s.slugify(pkg.name),
css: "assets/css",
js: "assets/js"
};
src = {
sass: {
main: "assets/scss/" + dist.name + ".scss",
files: ["assets/scss/**/**"]
},
js: {
fonts: [
"assets/vendor/fontfaceobserver/fontfaceobserver.js",
"assets/js/src/fonts.js"
],
main: [
"assets/js/src/__init.js",
"assets/js/src/main.js",
"assets/js/src/cover.js",
"assets/js/src/search.js"
],
vendor: [
"assets/js/src/libs/subbscribe.js",
"assets/vendor/ghostHunter/jquery.ghostHunter.min.js",
"assets/vendor/fitvids/jquery.fitvids.js",
"assets/vendor/reading-time/build/readingTime.min.js",
"assets/vendor/prism/prism.js",
"assets/vendor/prism/components/prism-python.js",
"assets/vendor/prism/components/prism-http.js",
"assets/vendor/prism/components/prism-bash.js",
"assets/vendor/prism/plugins/autolinker/prism-autolinker.js",
"assets/vendor/toastr/toastr.min.js",
"assets/vendor/store-js/store.min.js"
]
},
css: {
main: "assets/css/" + dist.name + ".css",
vendor: [
//"assets/vendor/prism/themes/prism-okaidia.css",
"assets/vendor/prism/themes/prism.css",
"assets/vendor/prism/plugins/autolinker/prism-autolinker.css"
]
},
fonts: {
files: [
"assets/vendor/font-awesome/fonts/**.*"
],
dest: "assets/fonts"
}
};
banner = ["/**", " * <%= pkg.name %> - <%= pkg.description %>", " * @version <%= pkg.version %>", " * @link <%= pkg.homepage %>", " * @author <%= pkg.author.name %> (<%= pkg.author.url %>)", " * @license <%= pkg.license %>", " */", ""].join("\n");
gulp.task("fonts", function() {
gulp.src(src.fonts.files)
.pipe(gulp.dest(src.fonts.dest));
});
gulp.task("css", ["fonts"], function() {
gulp.src(src.css.vendor).pipe(changed(dist.css)).pipe(addsrc(src.sass.main)).pipe(sass().on("error", gutil.log)).pipe(concat("" + dist.name + ".css")).pipe(prefix()).pipe(strip({
all: true
})).pipe(cssmin()).pipe(header(banner, {
pkg: pkg
})).pipe(gulp.dest(dist.css));
});
gulp.task("js", function() {
gulp.src(src.js.fonts).pipe(addsrc(src.js.main)).pipe(changed(dist.js)).pipe(addsrc(src.js.vendor)).pipe(concat("" + dist.name + ".js")).pipe(uglify({
mangle: false
})).pipe(header(banner, {
pkg: pkg
})).pipe(gulp.dest(dist.js));
});
gulp.task("server", function() {
browserSync.init(null, {
proxy: "http://127.0.0.1:" + PORT.GHOST,
files: ["assets/**/*.*"],
reloadDelay: 300,
port: PORT.BROWSERSYNC
});
});
gulp.task("build", ["css", "js"]);
gulp.task("default", function() {
gulp.start(["build", "server"]);
gulp.watch(src.sass.files, ["css"]);
gulp.watch(src.js.main, ["js"]);
gulp.watch(src.js.fonts, ["js"]);
return gulp.watch(src.js.vendor, ["js"]);
});