-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·143 lines (126 loc) · 4.13 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
/*!
* UnderTasker
* Copyright 2017 Tyler Rilling
* Licensed under MIT (https://github.com/underlost/Undertasker/blob/master/LICENSE)
*/
// grab our packages
var gulp = require('gulp'),
child = require('child_process');
jshint = require('gulp-jshint');
sass = require('gulp-sass');
sourcemaps = require('gulp-sourcemaps');
concat = require('gulp-concat');
autoprefixer = require('gulp-autoprefixer');
cleanCSS = require('gulp-clean-css');
rename = require('gulp-rename'); // to rename any file
uglify = require('gulp-uglify');
del = require('del');
stylish = require('jshint-stylish');
runSequence = require('run-sequence');
coffee = require('gulp-coffee');
gutil = require('gulp-util');
imagemin = require('gulp-imagemin');
git = require('gulp-deploy-git');
argv = require('minimist')(process.argv.slice(2));
// Cleans the web dist folder
gulp.task('clean', function () {
del(['dist/']);
});
// Copy fonts task
gulp.task('copy-fonts', function() {
gulp.src('inc/fonts/**/*.{ttf,woff,eof,svg,eot,woff2,otf}')
.pipe(gulp.dest('dist/fonts'));
// Copy Font scss
gulp.src('node_modules/components-font-awesome/scss/**/*.scss')
.pipe(gulp.dest('inc/sass/font-awesome'));
// Copy Font files
gulp.src('node_modules/components-font-awesome/fonts/**/*.{ttf,woff,eof,svg,eot,woff2,otf}')
.pipe(gulp.dest('dist/fonts'));
});
// Minify Images
gulp.task('imagemin', function() {
gulp.src('inc/img/**/*.{jpg,png,gif,ico}')
.pipe(imagemin())
.pipe(gulp.dest('dist/img'))
});
// Copy components
gulp.task('copy-components', function() {
gulp.src('node_modules/components-font-awesome/scss/**/*.*')
.pipe(gulp.dest('inc/sass/font-awesome'));
gulp.src('node_modules/bootstrap/scss/**/*.*')
.pipe(gulp.dest('inc/sass/bootstrap'));
});
gulp.task('install', function(callback) {
runSequence(
'copy-components', 'copy-fonts', callback
);
});
// Compile coffeescript to JS
gulp.task('brew-coffee', function() {
gulp.src('inc/coffee/*.coffee')
.pipe(coffee({bare: true}).on('error', gutil.log))
.pipe(gulp.dest('inc/js/coffee/'))
});
// CSS Build Task
gulp.task('build-css', function() {
return gulp.src('inc/sass/site.scss')
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(gulp.dest('dist/css'))
.pipe(cleanCSS())
.pipe(rename('site.min.css'))
.pipe(gulp.dest('dist/css'))
.on('error', sass.logError)
});
// Concat All JS into unminified single file
gulp.task('concat-js', function() {
return gulp.src([
//'node_modules/jquery/dist/jquery.min.js',
'node_modules/popper.js/dist/umd/popper.min.js',
'node_modules/bootstrap/dist/js/bootstrap.min.js',
'node_modules/jquery.easing/js/jquery.easing.js',
'node_modules/fullpage.js/dist/jquery.fullpage.js',
//'inc/js/navigation.js',
'inc/js/functions.js',
// Coffeescript
'inc/js/coffee/*.*',
])
.pipe(sourcemaps.init())
.pipe(concat('site.js'))
.pipe(sourcemaps.write('./maps'))
.pipe(gulp.dest('dist/js'));
});
// configure the jshint task
gulp.task('jshint', function() {
return gulp.src('inc/js/*.js')
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'));
});
// Shrinks all the js
gulp.task('shrink-js', function() {
return gulp.src('dist/js/site.js')
.pipe(uglify())
.pipe(rename('site.min.js'))
.pipe(gulp.dest('dist/js'))
});
// Default Javascript build task
gulp.task('build-js', function(callback) {
runSequence('concat-js', 'shrink-js', callback);
});
// configure which files to watch and what tasks to use on file changes
gulp.task('watch', function() {
gulp.watch('inc/js/**/*.js', ['build-js']);
gulp.watch('inc/sass/**/*.scss', ['build-css' ] );
});
// Default build task
gulp.task('build', function(callback) {
runSequence(
'copy-fonts', 'imagemin',
['build-css', 'build-js'], callback
);
});
// Default task will build the jekyll site, launch BrowserSync & watch files.
gulp.task('default', ['build', 'watch']);