-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
182 lines (164 loc) · 6.4 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
"use strict";
var gulp = require('gulp'),
del = require('del'),
{ NotificationPipe } = require('./gulp-utilities/gulp-notification-pipe.js'),
sass = require('gulp-sass')(require('sass')),
postcss = require('gulp-postcss'),
preset_env = require('postcss-preset-env'),
ts = require('gulp-typescript'),
webserver = require('gulp-webserver'),
clean_css = require('gulp-clean-css'),
uglify = require('gulp-uglify'),
// imagemin = require('gulp-imagemin'),
// responsive = require('gulp-responsive'),
seo = require('gulp-seo'),
rename = require('gulp-rename'),
stylesLoc = './src/styles/*.scss',
scriptsLoc = './src/scripts/*.ts',
stylesDest = './public/styles',
scriptsDest = './public/scripts',
plugins = [
preset_env({stage: 3, autoprefixer: {add: true, grid: "autoplace"}})
],
devWebserver = null,
watchStyles = null,
watchScripts = null;
// Setup for notification tasks
function compileCSS(success, error) {
return gulp.src(stylesLoc)
.pipe(sass().on('error', error))
.pipe(postcss(plugins).on('error', error))
.pipe(gulp.dest(stylesDest));
}
function compileJS(success, error) {
return gulp.src(scriptsLoc)
.pipe(ts({noImplicitAny: true}).on('error', error))
.pipe(gulp.dest(scriptsDest));
}
function buildDevelopmentWebserver(success, error) {
if (devWebserver != null) return;
return devWebserver = gulp.src('./public')
.pipe(webserver({
fallback: './index.html',
livereload: true
}).on('error', error));
}
function destroyDevelopmentWebserver(success, error) {
if (devWebserver == null) return;
return gulp.series(gulp.parallel(watchStyles.close(), watchScripts.close()), devWebserver.close());
}
function CleanCSS(success, error) {
return gulp.src(`${stylesDest}/*.css`)
.pipe(clean_css({level: 2}))
.pipe(gulp.dest(stylesDest));
}
function Uglify(success, error) {
return gulp.src(`${scriptsDest}/*.js`, {allowEmpty: true})
.pipe(uglify())
.pipe(gulp.dest(scriptsDest));
}
function ServeIndex(success, error) {
return gulp.src('./src/resume.html')
.pipe(rename({ basename: 'index'}))
.pipe(gulp.dest('./public'));
}
// Notification tasks
gulp.task('dev: BuildStyles', NotificationPipe(compileCSS, {message: "CSS compiled!"}));
gulp.task('dev: BuildScripts', NotificationPipe(compileJS, {message: "JavaScript compiled!"}));
gulp.task('dev: BuildPublic', NotificationPipe(ServeIndex, {message: "Public dist ready!"}));
gulp.task('dev: StartWebserver', NotificationPipe(buildDevelopmentWebserver, {message: "Dev webserver started!"}));
gulp.task('dev: StopWebserver', NotificationPipe(destroyDevelopmentWebserver, {message: "Dev webserver stopped!"}));
gulp.task('prod: MinifyStyles', NotificationPipe(CleanCSS, {message: "CSS minified!"}));
gulp.task('prod: MinifyScripts', NotificationPipe(Uglify, {message: "JavaScript minified!"}));
// silent tasks
gulp.task('clean', function() {
return del([`${stylesDest}/*.css`, `${scriptsDest}/*.js`], {force: true});
});
gulp.task('hotreload: WatchStyles', function() {
if (watchStyles != null) return;
return watchStyles = gulp.watch(stylesLoc, gulp.task('dev: BuildStyles'));
});
gulp.task('hotreload: WatchScripts', function() {
if (watchScripts != null) return;
return watchScripts = gulp.watch(scriptsLoc, gulp.task('dev: BuildScripts'));
});
gulp.task('hotreload: WatchHtml', function() {
return gulp.watch('./src/resume.html', gulp.task('dev: BuildPublic'));
});
gulp.task('prod: SEO', function() {
// gulp.src('./assets/images')
// .pipe(responsive({
// '*.png': [
// {
// width: 200,
// rename: {
// suffix: '-200'
// }
// },
// {
// width: 800,
// rename: {
// suffix: '-800'
// }
// },
// {
// width: 1000,
// rename: {
// suffix: '-1000'
// }
// }
// ],
// '*.jfif': [
// {
// width: 200,
// rename: {
// suffix: '-200'
// }
// },
// {
// width: 800,
// rename: {
// suffix: '-800'
// }
// },
// {
// width: 1000,
// rename: {
// suffix: '-1000'
// }
// }
// ]
// }))
// .pipe(imagemin([
// imagemin.mozjpeg({quality: 80, progressive: true}),
// imagemin.optipng({optimizationLevel: 1})
// ]))
// .pipe(gulp.dest('./assets/img'));
return gulp.src('./src/resume.html')
.pipe(seo({
list: ['og', 'se', 'schema', 'twitter'],
meta: {
type: 'website',
author: 'Jonathon Reese Perry',
webauthor: 'Jonathon Reese Perry',
locale: 'en_US',
url: 'https://JonathonRP.github.io/Resume/',
image: 'https://JonathonRP.github.io/Resume/assets/images/profile.png',
title: 'Jonathon Reese Perry Software Developer Resume',
description: 'Hard working and detail oriented professional, seeking a software development position where I can use my skills and contribute to the growth of a company.',
site_name: 'Software Developer Resume',
keywords: ['Software Developer', 'Web Developer', 'MVC 5', 'C#', '.Net', 'SQL'],
robots: {
index: true,
follow: true
},
revisitAfter: '1 month'
}
}))
.pipe(rename({ basename: 'index'}))
.pipe(gulp.dest('./public'));
});
// logical grouping tasks
gulp.task('dev: build', gulp.series('clean', gulp.parallel('dev: BuildStyles', 'dev: BuildScripts', 'dev: BuildPublic')));
gulp.task('start debugging', gulp.series('dev: build', gulp.parallel('hotreload: WatchStyles', 'hotreload: WatchScripts', 'dev: StartWebserver')));
gulp.task('prod: build', gulp.series('dev: build', gulp.parallel('prod: MinifyStyles', 'prod: MinifyScripts', 'prod: SEO')));