-
Notifications
You must be signed in to change notification settings - Fork 17
/
gulpfile.js
executable file
·102 lines (89 loc) · 2.97 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
var gulp = require('gulp'),
gutil = require('gulp-util'),
browserSync = require('browser-sync').create(),
ghPages = require('gulp-gh-pages'),
sass = require('gulp-sass'),
jshint = require('gulp-jshint'),
concat = require('gulp-concat'),
sourcemaps = require('gulp-sourcemaps'),
input = {
'sass': 'source/scss/**/*.scss',
'javascript': ['source/javascript/*.js'],
'vendorjs': 'source/javascript/vendor/*.js',
'html': ['source/*.html', 'source/*/*.html'],
'audio': 'source/audio/*.mp3'
},
output = {
'stylesheets': 'build/assets/stylesheets',
'javascript': 'build/assets/javascript',
'vendorjs': 'build/assets/javascript/vendor',
'html': 'build',
'audio': 'build/audio'
};
/* run javascript through jshint */
gulp.task('jshint', function() {
return gulp.src(input.javascript)
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'));
});
/* compile scss files */
gulp.task('build-css', function() {
return gulp.src('source/scss/**/*.scss')
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(sourcemaps.write())
.pipe(gulp.dest(output.stylesheets));
});
/* copy html files */
gulp.task('build-html', function(){
return gulp.src(input.html)
.pipe(gulp.dest(output.html));
});
/* copy html files */
gulp.task('build-audio', function(){
return gulp.src(input.audio)
.pipe(gulp.dest(output.audio));
});
/* concat javascript files, minify if --type production */
gulp.task('build-js', function() {
return gulp.src(input.javascript)
.pipe(sourcemaps.init())
.pipe(concat('main.js'))
//only uglify if gulp is ran with '--type production'
.pipe(gutil.env.type === 'production' ? uglify() : gutil.noop())
.pipe(sourcemaps.write())
.pipe(gulp.dest(output.javascript));
});
/* concat javascript files, minify if --type production */
gulp.task('build-vendorjs', function() {
return gulp.src(input.vendorjs)
.pipe(sourcemaps.init())
.pipe(concat('vendor.js'))
//only uglify if gulp is ran with '--type production'
.pipe(gutil.env.type === 'production' ? uglify() : gutil.noop())
.pipe(sourcemaps.write())
.pipe(gulp.dest(output.vendorjs));
});
// deploy
gulp.task('deploy', function() {
return gulp.src('build/**/*')
.pipe(ghPages());
});
// Static server
gulp.task('browser-sync', function() {
browserSync.init({
server: {
baseDir: "build"
}
});
});
/* Watch these files for changes and run the task on update */
gulp.task('watch', function() {
gulp.watch(input.javascript, ['jshint', 'build-js']);
gulp.watch(input.vendorjs, ['jshint', 'build-vendorjs']);
gulp.watch(input.sass, ['build-css']);
gulp.watch(input.html, ['build-html']);
});
/* run the watch task when gulp is called without arguments */
gulp.task('default', ['browser-sync', 'watch']);
gulp.task('build', ['build-js', 'build-vendorjs', 'build-css', 'build-html', 'jshint']);