-
Notifications
You must be signed in to change notification settings - Fork 11
/
gulpfile.js
142 lines (124 loc) · 3.96 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
'use strict';
// Include Gulp & Tools We'll Use
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var del = require('del');
var pagespeed = require('psi');
var htmlmin = require('gulp-htmlmin');
var replace = require('gulp-replace');
var pump = require('pump');
// Lint JavaScript
gulp.task('jshint', function() {
return gulp.src(['js/compline.js', 'js/chant-element.js', 'js/calendar.js'])
.pipe($.jshint())
.pipe($.jshint.reporter('jshint-stylish'));
});
// Copy All Files At The Root Level (app)
gulp.task('copy', function() {
return gulp.src([
'**/*.gabc',
'js/require.js',
'fonts/*.woff',
'fonts/*.woff2',
'!dist/**/*',
'!node_modules/**/*',
'!cordova/**/*'
], {
dot: true,
base: '.'
}).pipe(gulp.dest('dist'))
.pipe($.size({title: 'copy'}));
});
// Compile and Automatically Prefix Stylesheets
gulp.task('styles', function(cb) {
var requirejs = require('requirejs');
requirejs.optimize({
cssIn: "style.css",
out: "dist/style.css",
optimizeCss: "standard"
});
cb();
// return gulp.src([
// 'dist/*.css'
// ])
// // Concatenate And Minify Styles
// .pipe($.if('*.css', $.csso()))
// .pipe(gulp.dest('dist'))
// .pipe($.size({title: 'styles'}));
});
// Build one javascript file:
gulp.task('scripts', function(cb) {
var requirejs = require('requirejs');
requirejs.optimize({
'findNestedDependencies': true,
'baseUrl': './js/',
'name': 'compline',
'optimize': 'uglify2',
'out': './dist/js/compline.js',
'wrap': true,
// 'onModuleBundleComplete': function(data) {
// var fs = require('fs'),
// amdclean = require('amdclean'),
// outputFile = data.path;
// fs.writeFileSync(outputFile, amdclean.clean({
// 'wrap': {
// // This string is prepended to the file
// 'start': ';(function() {\n',
// // This string is appended to the file
// 'end': '\n}());'
// },
// removeUseStricts: false,
// shimOverrides: { jquery: 'jQuery' },
// 'filePath': outputFile
// }));
//}
});
cb();
});
// Concatenate And Minify JavaScript
gulp.task('scripts_old', function(cb) {
var sources = [
'js/*.js'
];
pump([
gulp.src(sources, {base: '.'}),
$.uglify(),
gulp.dest('dist'),
$.size({title: 'scripts'})
],
cb
);
});
// Scan Your HTML For Assets & Optimize Them
gulp.task('html', function() {
return gulp.src(['*.html', 'psalms/**/*.html'], {base: '.'})
// .pipe(replace(/data-main="([^"]+?)(?:\.js)?"\s+src="[^"]+\/require.js"/,'src="$1.js"'))
// Replace ǽ with æ, since the font we are using right now doesn't look right with the ǽ character,
// even when trying to use combining diacritics æ\u0301
// .pipe(replace('ǽ','æ'))
// The bold unicode accent character for producing œ́ doesn't work, so make sure the accent itself isn't bold
.pipe(replace(/(<b>[^<]+œ)(́)/g, '$1</b>$2<b>'))
// Minify Any HTML
.pipe(htmlmin({collapseWhitespace: true, removeComments: true}))
// Output Files
.pipe(gulp.dest('dist'))
.pipe($.size({title: 'html'}));
});
// Clean Output Directory
gulp.task('clean', del.bind(null, ['.tmp', 'dist/*', '!dist/.git'], {dot: true}));
// Build and serve the output from the dist build
// gulp.task('serve:dist', ['default']);
// Build Production Files, the Default Task
gulp.task('default', gulp.series(['html', 'styles', 'scripts', 'copy']));
// Run PageSpeed Insights
// Update `url` below to the public URL for your site
gulp.task('pagespeed', pagespeed.bind(null, {
// By default, we use the PageSpeed Insights
// free (no API key) tier. You can use a Google
// Developer API key if you have one. See
// http://goo.gl/RkN0vE for info key: 'YOUR_API_KEY'
url: 'https://compline.us.to',
strategy: 'mobile'
}));
// Load custom tasks from the `tasks` directory
// try { require('require-dir')('tasks'); } catch (err) { console.error(err); }