-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgulpfile.js
More file actions
141 lines (125 loc) · 3.86 KB
/
gulpfile.js
File metadata and controls
141 lines (125 loc) · 3.86 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
var gulp = require('gulp'),
browserSync = require('browser-sync').create(),
sass = require('gulp-sass')(require('sass')), autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
rename = require('gulp-rename'),
postcss = require('gulp-postcss'),
imageResize = require('gulp-image-resize'),
parallel = require("concurrent-transform"),
os = require("os"),
cp = require('child_process');
var messages = {
jekyllBuild: '<span style="color: grey">Running:</span> $ jekyll build'
}
/**
* Build the Jekyll Site
*/
function jekyllbuild (done) {
browserSync.notify(messages.jekyllBuild);
return cp.spawn('bundle', ['exec', 'jekyll', 'build', '--config=_config.yml'], {stdio: 'inherit'})
.on('close', done);
}
/**
* Build the dev Jekyll Site
*/
function jekyllbuildgitdocs (done) {
return cp.spawn('bundle', ['exec', 'jekyll', 'build', '--config=_config.yml,_config-dev.yml'], {stdio: 'inherit'})
.on('close', done);
}
/**
* Build the dev Jekyll Site for Jay
*/
function jekyllbuildjdb (done) {
return cp.spawn('bundle', ['exec', 'jekyll', 'build', '--config=_config.yml,_config-dev-jdb.yml'], {stdio: 'inherit'})
.on('close', done);
}
/**
* Wait for jekyll-build, then launch the Server
*/
function browsersync(cb) {
browserSync.init({
server: {
baseDir: 'docs'
},
startPath: "/index.html"
});
cb()
}
// var opacity = function(css) {
// css.eachDecl(function(decl, i) {
// if (decl.prop === 'opacity') {
// decl.parent.insertAfter(i, {
// prop: '-ms-filter',
// value: '"progid:DXImageTransform.Microsoft.Alpha(Opacity=' + (parseFloat(decl.value) * 100) + ')"'
// });
// }
// });
// };
/**
* Compile files from sass into both assets/css (for live injecting) and site (for future jekyll builds)
*/
function styles() {
return gulp.src('_scss/main.scss')
.pipe(sass({ outputStyle: 'expanded' }))
.pipe(autoprefixer())
//.pipe(postcss([opacity]))
.pipe(gulp.dest('assets/css'))
.pipe(rename({suffix: '.min'}))
.pipe(minifycss())
.pipe(gulp.dest('assets/css'));
};
/**
* Automatically resize post feature images and turn them into thumbnails
*/
function thumbnails () {
return gulp.src("assets/images/hero/*.{jpg,png}")
.pipe(parallel(
imageResize({ width : 350 }),
os.cpus().length
))
.pipe(gulp.dest("assets/images/thumbnail"));
};
/**
* Watch scss files for changes & recompile
* Watch html/md files, run jekyll
* Watch docs generation, reload BrowserSync
*/
function watch() {
gulp.watch('_scss/**/*.scss', styles);
gulp.watch('assets/images/hero/*.{jpg,png}', thumbnails);
gulp.watch(['*.html',
'*.txt',
'_chapters/*.md',
'_appendices/*.md',
'_pages/*.md',
'assets/javascripts/**/**.js',
'assets/images/**',
'assets/fonts/**',
'_layouts/**',
'_includes/**',
'assets/css/**'
],
jekyllbuild);
gulp.watch("docs/index.html").on('change', browserSync.reload);
}
var build = gulp.series(thumbnails, styles, jekyllbuild);
var buildjdb = gulp.series(thumbnails, styles, jekyllbuildjdb);
var builddeps = gulp.series(thumbnails, styles);
var dev = gulp.series(thumbnails, styles, jekyllbuild, browsersync, watch);
var devjdb = gulp.series(thumbnails, styles, jekyllbuildjdb, browsersync, watch);
/**
* Default task, running just `gulp` will compile the sass,
* compile the jekyll site, launch BrowserSync & watch files.
*/
exports.styles = styles;
exports.thumbnails = thumbnails;
exports.jekyllbuild = jekyllbuild;
exports.jekyllbuildgitdocs = jekyllbuildgitdocs;
exports.jekyllbuildjdb = jekyllbuildjdb;
exports.watch = watch;
exports.builddeps = builddeps;
exports.dev = dev;
exports.build = build;
exports.devjdb = devjdb;
exports.buildjdb = buildjdb;
exports.default = dev;