forked from MDJCL/MDJCL.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbabel_gulpfile.babel.js
410 lines (382 loc) · 14.9 KB
/
babel_gulpfile.babel.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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
// generated on 2015-06-15 using generator-gulp-webapp 1.0.0
/* use ./node_modules/babel-cli/bin/babel.js babel_gulpfile.babel.js > gulpfile.js */
import gulp from 'gulp';
import gulpLoadPlugins from 'gulp-load-plugins';
import browserSync from 'browser-sync';
import del from 'del';
import {
stream as wiredep
}
from 'wiredep';
const $ = gulpLoadPlugins();
const reload = browserSync.reload;
const runSequence = require("run-sequence")
gulp.task('styles', () => {
return gulp.src('app/styles/*.css').pipe($.sourcemaps.init()).pipe($.autoprefixer({
browsers: ['> 5% in US', 'last 1 version']
})).pipe($.sourcemaps.write()).pipe(gulp.dest('.tmp/styles')).pipe(reload({
stream: true
}));
});
function swallowError (error) {
// If you want details of the error in the console
console.log(error.toString())
this.emit('end')
}
function lint(files) {
// console.log("if want to run eslint /home/jonah/Dropbox/Public/MDJCL/yeoman/app/scripts/main.js ")
return () => {
return gulp.src(files).pipe(reload({
stream: true,
once: true
})).pipe($.eslint()).pipe($.eslint.format()).pipe($.if(!browserSync.active, $.eslint.failAfterError()))
};
}
gulp.task('lint', lint('app/scripts/**/*.js'));
gulp.task('lint:test', lint('test/spec/**/*.js'));
gulp.task('html', ['styles', 'copyGoogle'], () => {
const assets = $.useref.assets({
searchPath: ['.tmp', 'app', '.']
});
return gulp.src(['app/*.html', '!app/google9fd3a51767af392b.html']).pipe($.inlineSource()).pipe(assets).pipe($.if('*.js', $.uglify())).pipe($.if('*.css', $.cleanCss({
compatibility: '*'
}))).pipe(assets.restore()).pipe($.useref()).pipe($.if('*.html', $.minifyHtml({
conditionals: true,
loose: true
}))).pipe(gulp.dest('dist'));
});
gulp.task('copyGoogle', () => {
return gulp.src("app/google9fd3a51767af392b.html").pipe(gulp.dest('dist'))
})
gulp.task('resizeGallery', () => {
console.log("Run batchcrop.js and make sure no sideways/etc pictures")
// return
// // return gulp.src('batchcrop.js').pipe($.util.log("Run batchcrop.js and make sure no sideways/etc pictures"))
return gulp.src('app/images/miscGallery/*').pipe($.responsive({
'*': {
// width: 434,
// height: 290,
width: 651,
height: 435,
rename: {
suffix: "-resized"
},
withoutEnlargement: false
}
}, {
errorOnUnusedImage: false
})).pipe(gulp.dest('app/images/resized/miscGallery'))
})
gulp.task('resize', () => {
//resize images here
var path = 'app/images/*'
var args = process.argv
console.log(args)
console.log(args.length)
if (args.length > 3) {
console.log("HAS EXTRA ARGS" + args)
//removes first 3 from ie [ 'node', 'path/to/gulp.js', '--option', '123' ]
args = args.splice(3)
path = []
for (var i in args) {
path.push("app/images/" + args[i].replace(/\-/g, ""))
}
//changes ending comma to ending bracket
}
return gulp.src(path).pipe($.responsive({
//for documents, after remove all surrounding whitespace, run `montage null: Constit.png -tile 2x1 -geometry +3+0 out2.png` to add the right amount of whitespace so it doesn't go over edge
'{Laurel.jpg,Watch.jpg,Help.jpg,Nervs.jpg,NationalConvention0021.jpg,NationalConvention0007.jpg,dropboxLogo.jpg,twitterLogo.png,instagramLogo.jpg,facebookLogo.png,envelopeLogo.jpg,MagistraKunzConvention_0005.jpg,Dulanium*,EleanorCertamen1.jpg,pastOfficers*,SaturnaliaCertamen*,Oct31*,Convention_Dulaney_1831.JPG,MagistraKunzConvention_finalcertamen2.JPG,MagistraKunzConvention_gladiator4.JPG,MagistraKunzConvention_talentshow3.JPG,Convention_Dulaney_1674.JPG,MagistraKunzConvention_0072.jpg,MagistraKunzConvention_0215.jpg,MagistraKunzConvention_0268.jpg,MagistraKunzConvention_0369.jpg,MagistraKunzConvention_0151.jpg,MagistraKunzConvention_Greekdancing.png,pegaFrog2.jpg,pegaFrog3.jpg,eastonVA.jpg,eastonVA2.jpg,Dulaney_movie1.jpg,Dulaney_movie3.jpg,Dulaney_movie4.jpg,Dulaney_gladiator1.jpg,Dulaney_gladiator2.jpg,Dulaney_gladiator3.jpg,Dulaney_gladiator4.jpg,Dulaney_gladiator5.jpg,Dulaney_gladiator6.jpg,Dulaney_gladiator7.jpg,Dulaney_gladiator8.jpg,Dulaney_gladiator10.jpg,Dulaney_gladiator11.JPG,MuseumVisit4.jpg,MuseumVisit5.jpg,MuseumVisit6.jpg,MuseumVisit0.jpg,MuseumVisit4.jpg,MuseumVisit8.jpg,NewConvention1.jpg,NewConvention3.jpg,overallForm.jpg}': {
//for 4/12
width: 430,
height: 287,
rename: {
suffix: "-resized"
},
withoutEnlargement: false
},
'{NJCL_smaller.jpg,Exercise.jpg,Stand.jpg,peepcontest2.png,NationalConvention0004.jpg,ContactUs.png,MainDulanium.jpg,EleanorCertamen2.jpg,MagistraKunzConvention_0353.jpg,pegaFrogOriginal.jpg,pegaFrog1.jpg,eastonVA3.jpg,Dulaney_movie2.jpg,Dulaney_gladiator9.jpg,MuseumVisit1.jpg,NewConvention2.jpg,MagistraKunzConvention_0152.jpg}': {
//for 8/12 sized
width: 873,
height: 580,
rename: {
suffix: "-resized"
},
withoutEnlargement: false
},
'{Chariot.jpg,}': {
//for 3/12
width: 325,
height: 433,
rename: {
suffix: "-resized"
}
},
'{OfficerElection.png,ConventionSchedule.png,Vulpes.png}': {
//for 6/12
width: "100%",
height: 522,
rename: {
suffix: "-resized"
},
withoutEnlargement: false
},
'{confused*,Jonah.jpg,EllaJoshi.jpg,MsKunzResized.jpg,Liz.jpg,EllieResized.jpg,Edmund.jpg,Katie.jpg,JonahPlant.jpg,MsKunz2Resized.jpg,MsKunz3Resized.jpg,MsKunz4Resized.jpg,Liz2.jpg,Liz2Resized.jpg,Ellie2.jpg,Ellie2Resized.jpg,RomanWantsYou.jpg,samWants.jpg,linganore.jpg,pastOfficers*,EastonBakeSale*,EastonAdoptFamily.jpg,EastonGeneral.jpg,POTUS.jpg,VPOTUS.jpg,lawLogo.png,editorLogo.jpg,webmasterLogo.jpg}': {
//for stricter 6/12
width: 654,
height: 437,
rename: {
suffix: "-resized"
},
withoutEnlargement: false
},
'{Registration.png,Constit.png,PurpleGold.jpg,Creed.jpg,coliseum.png,questionMarks.jpg,questionMarks.jpg,PastTorch*,moreComing.jpg,museum.jpg,spellingBee.jpg,certamen.jpg,Minotaur404.jpg,LHHomeless.jpg,olimPaper.jpg,tShirtTorso.jpg,tShirtTorsoSmaller.jpg,2015_Fall_Torch.jpg,MuseumDay.jpg,2015_Winter_Torch.jpg,MDJCLPin.png,ERHS_Spelling.jpg,convention2016.jpg,allT.jpg,SpringTorch.jpg,editorLogoResized.jpg,ConventionTorch.jpg,congrats.jpg,Meeting*.jpg}': {
width: "100%",
height: "100%",
rename: {
suffix: "-resized"
}
},
'{easton.jpg,dulaney.JPG,countrySchool.jpg,loyola.jpg,eleanor.jpg,EastonParty.jpg}': {
width: "654",
height: "100%",
rename: {
suffix: "-resized"
},
withoutEnlargement: false
}
}, {
errorOnUnusedImage: false,
errorOnUnusedConfig: false
})).pipe(gulp.dest('app/images/resized'))
})
gulp.task('deploy', function() {
//build needs to be already done
return gulp.src("./dist/**/*").pipe($.ghPages({
"branch": "master",
"remoteUrl": "https://github.com/MDJCL/MDJCL.github.io.git"
}))
});
gulp.task('spellcheck', function() {
// throw "didn't work"
return gulp.src('app/index.html')
// .pipe($.util.log("aspell check -H /home/jonah/Dropbox/Public/MDJCL/yeoman/index.html"))
.pipe($.spellcheck({
"stdout": true,
"mode": "html",
"ignore": ["Linganore", "Ballenger", "th", "linganorelatin", "Dulanium", "Padonia", "linganorelatin","Padonia","Goldsborough","pegafrog", "ientaculum", "USD", "Chaperone", "Marsandi", "Zhao","nd"]
}))
// .pipe($.util.log())
.pipe($.prompt.confirm({
message: 'Continue? If not aspell check -H /home/jonah/Dropbox/Public/MDJCL/app/index.html',
default: true
})).
.on('error', $.util.log)
// .pipe(gulp.dest('app'));
});
gulp.task('images', ['resize'], () => {
console.log("If only wanted specific images/globs, pass in '--GLOB/NAME HERE'")
var path = 'app/images/resized/**/*'
var args = process.argv
if (args.length > 3) {
console.log("HAS EXTRA ARGS" + args)
//removes first 3 from ie [ 'node', 'path/to/gulp.js', '--option', '123' ]
args = args.splice(3)
path = []
for (var i in args) {
path.push("app/images/resized/" + args[i].replace(/\-/g, ""))
}
//changes ending comma to ending bracket
}
return gulp.src(path).pipe($.if($.if.isFile, $.cache($.imagemin({
progressive: true,
interlaced: true,
// don't remove IDs from SVGs, they are often used
// as hooks for embedding and styling
svgoPlugins: [{
cleanupIDs: false
}]
})))
.on('error', function(err) {
console.log(err);
this.end();
})).pipe(gulp.dest('dist/images/resized'));
});
gulp.task('clear', function(done) {
return $.cache.clearAll(done);
});
gulp.task('docs', () => {
return gulp.src('app/Docs/**/*').pipe(gulp.dest('dist/Docs'))
})
gulp.task('fonts', () => {
return gulp.src(require('main-bower-files')({
filter: '**/*.{eot,svg,ttf,woff,woff2}'
}).concat('app/fonts/**/*')).pipe(gulp.dest('.tmp/fonts')).pipe(gulp.dest('dist/fonts'));
});
gulp.task('extras', () => {
return gulp.src(['app/*.*', '!app/*.html'], {
dot: true
}).pipe(gulp.dest('dist'));
});
gulp.task('clean', del.bind(null, ['.tmp', 'dist']));
gulp.task('serve', ['styles', 'fonts'], () => {
browserSync({
notify: false,
port: 9000,
server: {
baseDir: ['.tmp', 'app'],
routes: {
'/bower_components': 'bower_components'
}
}
});
gulp.watch(['app/*.html', 'app/scripts/**/*.js', '.tmp/fonts/**/*']).on('change', reload);
//jonah
// gulp.watch('app/images/*', ['images']);
//end jonah
gulp.watch('app/styles/**/*.css', {
debounceDelay: 2000
}, ['styles']);
gulp.watch('app/fonts/**/*', ['fonts']);
gulp.watch('bower.json', ['wiredep', 'fonts']);
});
gulp.task('serve:dist', () => {
browserSync({
notify: false,
port: 9000,
server: {
baseDir: ['dist']
}
});
});
// gulp.task('googleCDN', () => {
// return gulp.src('index.html')
// .pipe(gulp.dest('dist'));
// });
gulp.task('serve:test', () => {
browserSync({
notify: false,
open: false,
port: 9000,
ui: false,
server: {
baseDir: 'test'
}
});
gulp.watch('test/spec/**/*.js').on('change', reload);
gulp.watch('test/spec/**/*.js', ['lint:test']);
});
// inject bower components
gulp.task('wiredep', () => {
gulp.src('app/*.html').pipe(wiredep({
exclude: ['bootstrap.js'],
ignorePath: /^(\.\.\/)*\.\./
})).pipe(gulp.dest('app'));
});
gulp.task('build', ['html', 'images', 'fonts', 'extras'], (cb) => {
//tdd
// gulp.task('build', ['html', 'fonts', 'extras'], (cb) => {
gulp.src('dist/**/*').pipe($.size({
title: 'build',
gzip: true
}));
cb("")
});
gulp.task('validateHTML', () => {
console.log("If have errors, run ':make' on the html in VIM and use ':cn for next'")
return gulp.src('app/index.html')
.pipe($.html())
});
gulp.task('noCritical', (callback) => {
// runSequence(['clean', 'spellcheck'], 'docs', 'build', 'deploy', callback);
runSequence(['clean', 'spellcheck', 'lint', "validateHTML"], 'docs', 'build', 'sitemap', callback);
});
gulp.task('default', function(callback) {
// runSequence(['clean', 'spellcheck'], 'docs', 'build', 'critical', 'deploy', callback);
console.log("gulp deploy")
console.log("eslint /home/jonah/Dropbox/Public/MDJCL/app/scripts/main.js ")
console.log("aspell check -H /home/jonah/Dropbox/Public/MDJCL/app/index.html")
// runSequence(['clean', 'spellcheck', "lint","validateHTML"], 'docs', 'build', 'sitemap', 'critical', callback);
runSequence(['clean', 'spellcheck', "lint","validateHTML"], 'docs', 'build', 'sitemap', callback);
});
gulp.task('sitemap', function() {
return gulp.src(['dist/index.html', 'dist/Docs/*'])
.pipe($.sitemap({
siteUrl: 'https://mdjcl.github.io',
changefreq: "weekly",
// pages: ["*"],
verbose: true
}))
.pipe(gulp.dest('./dist'));
});
gulp.task('copystyles', function() {
return gulp.src(['dist/styles/main.css']).pipe($.rename({
basename: "site" // site.css
})).pipe(gulp.dest('dist/styles'));
});
gulp.task('critical', ['copystyles'], function(cb) {
return gulp.src('dist/*.html')
.pipe(require('critical').stream({
// Inline the generated critical-path CSS
// - true generates HTML
// - false generates CSS
inline: true,
// Your base directory
base: 'dist/',
// HTML source
// HTML source file
// src: 'index.html',
// Target for final HTML output.
// use some css file when the inline option is not set
// dest: 'index-critical.html',
// // Minify critical-path CSS when inlining
minify: true,
// // Extract inlined styles from referenced stylesheets
extract: true,
// Prefix for asset directory
// ignore css rules
ignore: ['@font-face', '.btn']
})).pipe(gulp.dest('dist'));
// critical.generateInline({
// inline: true,
// base: 'dist/',
// src: 'index.html',
// // htmlTarget: 'index.html',
// dest: 'index-critical.html',
// minify: true,
// width: 1300,
// height: 900,
// ignore: ['@font-face', /url\(/,/SIFONN_BASIC/g, 'font', /font/, /font/g, /@font-face/g]
// }, cb.bind(cb));
});
gulp.task("checkDev", function(callback) {
console.log("HAVING gulp.serve RUNNING")
console.log("RUN gulp checkDev 2>&1 >/dev/null")
var options = {
pageUrls: [
'http://localhost:9000/'
],
checkLinks: true,
// onlySameDomain: true,
// queryHashes: true,
// noRedirects: true,
// noLocalLinks: true
// noEmptyFragments: true,
linksToIgnore: [
'http://localhost:9000/#'
],
// checkXhtml: true,
// checkCaching: true,
// checkCompression: true,
// maxResponseTime: 200,
// userAgent: 'custom-user-agent/1.2.3',
// summary: true
};
require("check-pages")(console, options, function(err, b, c){
console.log("ERRROR: ")
console.log(err)
console.log("----")
console.log(b)
console.log("----")
console.log(c)
});
});