-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
97 lines (75 loc) · 2.57 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
var gulp = require('gulp-help')(require('gulp'), {hideDepsMessage: true}),
util = require('gulp-util'),
gulpif = require('gulp-if'),
plumber = require('gulp-plumber'),
notify = require('gulp-notify'),
browserSync = require('browser-sync').create();
var production = util.env.production || false,
allowlint = util.env.allowlint || false,
stagingUrl = util.env.stagingUrl || false,
mobile = util.env.desktop || false,
slug = util.env.slug || '';
// Override standard gulp.src task to use plumber
var _gulpsrc = gulp.src;
gulp.src = function() {
return _gulpsrc.apply(gulp, arguments)
.pipe(gulpif(!production, plumber({
errorHandler: function(err) {
notify.onError("Error: " + err.toString())(err);
this.emit('end');
}
})));
};
// Compile SCSS to CSS
require('./gulp/styles')(gulp, production, browserSync);
// Lints scss files
require('./gulp/styles-lint')(gulp, production, allowlint);
// Critical path css
require('./gulp/styles-critical')(gulp, util);
// Concatenate & Minify JS
require('./gulp/scripts')(gulp, production, browserSync);
// Lint js files
require('./gulp/scripts-lint')(gulp, production, allowlint);
// Min / Crush images
require('./gulp/images')(gulp, production);
// Minify SVGS + run sprite task
require('./gulp/svgs')(gulp);
// Create SVG sprite file
require('./gulp/svg-sprite')(gulp, production);
// Copy font files from assets to dist
require('./gulp/fonts')(gulp);
// Lint PHP files using ruleset.xml
require('./gulp/php-lint')(gulp, allowlint, production);
// Validate files using PHP Mess Dectector
require('./gulp/php-md')(gulp);
// Deletes the build folder entirely.
require('./gulp/clean')(gulp);
// Browser sync for the Ngrok tunnel
require('./gulp/browser-sync')(gulp, browserSync);
// Ngrok for tunnels
require('./gulp/ngrok')(gulp, util, browserSync);
// Google Page Speed Insights
require('./gulp/psi')(gulp, util, slug, mobile);
// W3C HTML validation
require('./gulp/w3c-validate')(gulp, util, slug);
// WAVE Accessibility validation
require('./gulp/wave')(gulp, util, slug);
// Watch Files For Changes
require('./gulp/watch')(gulp, browserSync);
// Generic build task. Use with '--production' for production builds
gulp.task('build',
'Main build task. Runs styles, scripts, images, svgs, fonts and php:lint. Does not delete dist directory.', [
'images',
'svgs',
'styles',
'scripts',
'fonts'
]
);
gulp.task('default',
'Runs the build task. Deleting the dist directory first.',
['clean'],
function() {
gulp.start('build');
}
);