forked from podlove/podlove-subscribe-button
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
94 lines (83 loc) · 2.45 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
'use strict';
var gulp = require('gulp'),
gutil = require('gulp-util'),
sass = require('gulp-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', './src/html/popup.html'],
images: ['./src/images/**'],
fonts: ['./src/fonts/**']
};
gulp.task('stylesheets', function() {
return gulp.src(paths.stylesheets)
.pipe(sourcemaps.init())
.pipe(sass({style: 'compressed'}))
.pipe(autoprefixer({ browsers: ['last 5 versions'] }))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist/stylesheets'))
.pipe(gzip())
.pipe(gulp.dest('./dist/stylesheets'))
.pipe(connect.reload())
})
gulp.task('javascripts', function() {
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())
})
gulp.task('html', function() {
gulp.src(paths.html)
.pipe(gulp.dest('./dist'))
.pipe(connect.reload())
})
gulp.task('images', function() {
gulp.src(paths.images)
.pipe(gulp.dest('./dist/images'))
.pipe(connect.reload())
})
gulp.task('fonts', function() {
gulp.src(paths.fonts)
.pipe(gulp.dest('./dist/fonts'))
.pipe(connect.reload())
})
gulp.task('default', ['stylesheets', 'javascripts', 'html', 'images', 'fonts'])
gulp.task('watch', function() {
// 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'])
})
gulp.task('connect', function() {
connect.server({
root:'./',
livereload: true
});
});
// Serve
gulp.task('serve', ['default', 'connect', 'watch']);