-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
103 lines (73 loc) · 1.98 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
'use strict';
// Include Gulp & tools
var gulp = require('gulp');
var del = require('del');
var watch = require('gulp-watch');
var haml = require('gulp-haml');
var sass = require('gulp-sass');
var uglify = require('gulp-uglify');
var autoprefixer = require('gulp-autoprefixer');
var browserSync = require('browser-sync');
var runSequence = require('run-sequence');
var imagemin = require('gulp-imagemin');
var pngquant = require('imagemin-pngquant');
var concat = require('gulp-concat');
var reload = browserSync.reload;
// HAML
gulp.task('haml', function() {
return gulp.src('./app/index.haml')
.pipe(haml())
.pipe(gulp.dest('./build'));
});
// SASS
gulp.task('sass', function () {
return gulp.src('./app/styles/*.scss')
.pipe(sass())
.pipe(autoprefixer())
.pipe(gulp.dest('./build/styles'));
});
// Lint JavaScript
gulp.task('js', function(){
return gulp.src(
['./app/js/script.js'])
.pipe(concat('app.js'))
.pipe(uglify())
.pipe(gulp.dest('./build/js'));
});
// Images Min Task
gulp.task('images', function () {
return gulp.src('./app/images/**')
.pipe(imagemin({
progressive: true,
svgoPlugins: [{removeViewBox: false}],
use: [pngquant()]
}))
.pipe(gulp.dest('./build/images'));
});
// Copy Fonts
gulp.task('copy:fonts', function() {
return gulp.src('./app/font/**/*')
.pipe(gulp.dest('./build/font'));
});
// Watch Files & Reload
gulp.task('serve', function() {
browserSync({
server: {
baseDir: "./build"
}
});
gulp.watch(['./app/index.haml'], ['haml', reload]);
gulp.watch('./app/styles/**/*.scss', ['sass', reload]);
});
// Clean the Build Output Directory
gulp.task('clean', function() {
del(['build/*']);
});
// Build
gulp.task('build', ['clean'], function() {
runSequence('haml', 'sass', 'images', 'js', 'copy:fonts');
});
// Gulp Default
gulp.task('default', ['clean'], function() {
gulp.start('build');
});