-
Notifications
You must be signed in to change notification settings - Fork 97
/
gulpfile.js
129 lines (118 loc) · 3.58 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
"use strict";
var PORT, _s, 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");
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: [
"node_modules/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"
],
node_modules: [
"assets/js/src/libs/subbscribe.js",
"node_modules/ghosthunter/dist/jquery.ghosthunter.js",
"node_modules/fitvids/fitvids.min.js",
"node_modules/prismjs/prism.js",
"node_modules/toastr/build/toastr.min.js",
"node_modules/store/dist/store.modern.min.js"
]
},
css: {
main: "assets/css/" + dist.name + ".css",
node_modules: [
"node_modules/prismjs/themes/prism-okaidia.css",
]
},
fonts: {
files: [
"node_modules/\@fortawesome/fontawesome-free/webfonts/**.*"
],
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");
function fonts() {
return gulp.src(src.fonts.files)
.pipe(gulp.dest(src.fonts.dest));
}
function css() {
return gulp.src(src.css.node_modules)
.pipe(changed(dist.css))
.pipe(gulp.src(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));
}
function js() {
return gulp.src(src.js.fonts)
.pipe(gulp.src(src.js.main))
.pipe(changed(dist.js))
.pipe(gulp.src(src.js.node_modules))
.pipe(concat(dist.name + ".js"))
.pipe(uglify({
mangle: false
}))
.pipe(header(banner, {
pkg: pkg
}))
.pipe(gulp.dest(dist.js));
}
function server() {
return browserSync.init(null, {
proxy: "http://127.0.0.1:" + PORT.GHOST,
files: ["assets/**/*.*"],
reloadDelay: 300,
port: PORT.BROWSERSYNC
});
}
function watch() {
gulp.watch(src.sass.files).on("all", css);
gulp.watch(src.js.main).on("all", js);
gulp.watch(src.js.fonts).on("all", js);
return gulp.watch(src.js.node_modules).on("all", js);
}
gulp.task("fonts", fonts);
gulp.task("css", gulp.series("fonts", css));
gulp.task("js", js);
gulp.task("server", server);
gulp.task("build", gulp.series("css", "js"));
gulp.task("default", gulp.series("build", "server", watch));