-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathgulpfile.js
105 lines (89 loc) · 2.53 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
'use strict';
var gulp = require('gulp'),
sass = require('gulp-sass')(require('sass')),
coffee = require('gulp-coffee'),
watch = require('gulp-watch'),
uglify = require('gulp-uglify'),
concat = require('gulp-concat'),
browserify = require('gulp-browserify'),
rename = require('gulp-rename'),
connect = require('gulp-connect'),
sourcemaps = require('gulp-sourcemaps'),
autoprefixer = require('gulp-autoprefixer'),
gzip = require('gulp-gzip');
var dest = './dist';
var paths = {
stylesheets: ['./src/stylesheets/*.scss'],
main_javascript: ['./src/coffee/app.coffee'],
javascripts: ['./src/coffee/*.coffee'],
html: ['./src/html/button.html'],
images: ['./src/images/**'],
fonts: ['./src/fonts/**']
};
gulp.task('stylesheets', function() {
return gulp.src(paths.stylesheets)
.pipe(sourcemaps.init())
.pipe(sass({style: 'compressed'}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist/stylesheets'))
.pipe(gzip())
.pipe(gulp.dest('./dist/stylesheets'))
.pipe(connect.reload())
})
gulp.task('javascripts', function(done) {
gulp.src(paths.main_javascript, {read: false})
.pipe(browserify({
transform: ['coffeeify'],
extensions: ['.coffee']
}))
.pipe(uglify())
.pipe(rename('app.js'))
.pipe(gulp.dest('./dist/javascripts'))
.pipe(gzip())
.pipe(gulp.dest('./dist/javascripts'))
.pipe(connect.reload())
done()
})
gulp.task('html', function(done) {
gulp.src(paths.html)
.pipe(gulp.dest('./dist'))
.pipe(connect.reload())
done()
})
gulp.task('images', function(done) {
gulp.src(paths.images)
.pipe(gulp.dest('./dist/images'))
.pipe(connect.reload())
done()
})
gulp.task('fonts', function(done) {
gulp.src(paths.fonts)
.pipe(gulp.dest('./dist/fonts'))
.pipe(connect.reload())
done()
})
gulp.task('default', gulp.series('stylesheets', 'javascripts', 'html', 'images', 'fonts'))
gulp.task('watch', function(done) {
gulp.parallel(
// Watch .scss files
() => gulp.watch(paths.stylesheets, ['stylesheets']),
// Watch .js files
() => gulp.watch(paths.javascripts, ['javascripts']),
// Watch .html files
() => gulp.watch(paths.html, ['html']),
// Watch images files
() => gulp.watch(paths.images, ['images']),
// Watch font files
() => gulp.watch(paths.fonts, ['fonts']),
);
done()
})
gulp.task('connect', function(done) {
connect.server({
root:'./',
livereload: true
});
done();
});
// Serve
gulp.task('serve', gulp.series('default', 'connect', 'watch'));