-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgulpfile.js
More file actions
143 lines (109 loc) · 3.74 KB
/
Copy pathgulpfile.js
File metadata and controls
143 lines (109 loc) · 3.74 KB
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
// Gulp specific modules
var gulp = require("gulp");
var runSequence = require("run-sequence");
// File/folder handling modules
var del = require("del");
var path = require("path");
// Logger modules
var gutil = require("gulp-util");
var colors = gutil.colors;
// Reading package.json file
var pkg = require("./package.json");
var props = pkg.props;
var buildMode = process.argv[2] || "dev";
// Data variables
var config = {
pkg: pkg,
buildMode: buildMode
};
// This 'dataStore' is the context for all handlebar templates
var dataStore = {
tags: [],
blogs: []
};
//Polyfill
require("es6-promise").polyfill();
// System wide paths
var paths = (function () {
var src = "./src/";
return {
src: src,
dest: "./dist/",
js: "./js/",
icons: src + "/img/svg-icons/",
templates: src + "templates/",
partials: src + "templates/partials/",
resources: props.resources,
jsBundle: props.jsBundle,
jsBundleName: "bundle.js"
};
})();
// File selection filters
var filters = (function () {
return {
all: "**/*.*",
js: "**/*.js",
md: "**/*.md",
svg: "**/*.svg",
scss: "**/*.scss",
html: "**/*.html",
mdhtml: "**/*.{md,html}",
fonts: "**/*.{eot,svg,ttf,woff,woff2}",
images: "**/*.{png,jpg,jpeg,gif}",
templates: "**/*.hbs",
pagination: "**/*.collection",
yaml: "**/*.{yaml,yml}"
};
})();
// Clean the dist directory
del.sync([paths.dest]);
// Gulp task - copy
require("./gulp/gulp-copy.js")(paths, filters);
// Gulp task - data-store
var taskDataStore = require("./gulp/gulp-data-store.js")(paths, filters, config, dataStore);
// Handlebar utilities
var taskHandlebar = require("./gulp/gulp-handlebar.js")(paths, filters, config, dataStore);
// Gulp task - html
var taskHtml = require("./gulp/gulp-html.js")(paths, filters, config, dataStore);
// Gulp task - js
var taskJs = require("./gulp/gulp-js.js")(paths, filters, config, dataStore);
// Gulp task - paginate
var taskJs = require("./gulp/gulp-collection.js")(paths, filters, config, dataStore);
// Gulp task - sass
var taskSass = require("./gulp/gulp-sass.js")(paths, filters, config);
// Gulp task - svg-sprite
var taskSvg = require("./gulp/gulp-svg.js")(paths, filters, config, dataStore);
// Shared utilities
var utils = require("./gulp/gulp-utils.js")
// Gulp task - default, release, test, common
require("./gulp/gulp-run.js");
gulp.task("watcher", function (done) {
gulp.watch([paths.src + filters.scss], function (event) {
taskSass.pipeline([event.path, "./scss/main.scss"]);
gutil.log("Modified:", colors.yellow(getRelativePath(event.path)));
});
gulp.watch([filters.mdhtml], { cwd: paths.src }, function (event) {
taskHtml.pipeline(event.path);
gutil.log("Modified:", colors.yellow(getRelativePath(event.path)));
});
gulp.watch(filters.js, { cwd: paths.src }, function (event) {
taskJs.pipeline(event.path);
gutil.log("Modified:", colors.yellow(getRelativePath(event.path)));
});
// Since app.js is part of jsbundle, create watch on this file and execute jsbundle task.
gulp.watch("js/app.js", { cwd: paths.src }, ["jsbundle"]);
gulp.watch(filters.templates, { cwd: paths.templates }, function (event) {
if (event.path.indexOf("partials")) {
taskHandlebar.registerPartials();
}
runSequence("html", function () {
gutil.log("Modified:", colors.yellow(getRelativePath(event.path)));
});
});
done();
function getRelativePath(modifiedPath) {
return path.relative(process.cwd() + "/" + paths.src, modifiedPath);
}
});
taskHandlebar.registerPartials();
taskHandlebar.registerHelpers();