-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
74 lines (63 loc) · 1.51 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
/* jshint node: true */
"use strict";
var gulp = require("gulp");
var $ = require("gulp-load-plugins")();
var autoprefixer = require("autoprefixer");
var cssnano = require("cssnano");
/**
* copy js files from node_modules into the theme
*/
gulp.task("copy:js", function() {
return gulp
.src([
"node_modules/iscroll/build/iscroll.js",
"node_modules/jquery/dist/jquery.slim.js",
"node_modules/jquery-mousewheel/jquery.mousewheel.js",
"node_modules/pjax/pjax.js"
])
.pipe(gulp.dest("themes/sudo/source/js/vendor"));
});
/**
* after running hexo generate, cachebust the assets for production
*/
gulp.task("build", function() {
return (
gulp
.src("public/**/*", {
nodir: true
})
// concat build blocks
.pipe(
$.if(
["**/*.html"],
$.useref({
searchPath: "public"
})
)
)
// autoprefix & minify css
.pipe(
$.if(
"*.css",
$.postcss([
autoprefixer(),
cssnano({
safe: true,
mergeRules: false
})
])
)
)
// uglify js
.pipe($.if("*.js", $.uglifyEs.default()))
// rev assets
.pipe($.if(["**/*", "!**/*.html", "!**/*.xml"], $.rev()))
// replace cachebusted asset references in source files
.pipe(
$.revReplace({
replaceInExtensions: [".css", ".html", ".js", ".xml"]
})
)
.pipe(gulp.dest("public"))
);
});