forked from podigee/podigee-podcast-player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
136 lines (120 loc) · 3.44 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
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');
gzip = require('gulp-gzip');
fs = require('fs');
s3 = require('gulp-s3');
var dest = './dist';
var paths = {
main_stylesheet: ['./src/stylesheets/app.scss'],
stylesheets: ['./src/stylesheets/*.scss'],
main_javascript: ['./src/javascripts/app.coffee'],
javascripts: ['./src/javascripts/**/*.coffee'],
html: ['./src/html/podigee-podcast-player.html', './src/html/embed-example.html'],
images: ['./src/images/**'],
fonts: ['./vendor/fonts/**'],
themes: {
html: ['./src/themes/**/index.html'],
css: ['./src/themes/**/*.scss']
}
};
gulp.task('stylesheets', function() {
return gulp.src(paths.main_stylesheet)
.pipe(sass({style: 'compressed'}))
.pipe(gulp.dest('./build/stylesheets'))
.pipe(gzip())
.pipe(gulp.dest('./build/stylesheets'))
})
gulp.task('stylesheets-dev', function() {
return gulp.src(paths.main_stylesheet)
.pipe(sass())
.pipe(gulp.dest('./build/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('podigee-podcast-player.js'))
.pipe(gulp.dest('./build/javascripts'))
.pipe(gzip())
.pipe(gulp.dest('./build/javascripts'))
})
gulp.task('javascripts-dev', function() {
gulp.src(paths.main_javascript, {read: false})
.pipe(browserify({
transform: ['coffeeify'],
extensions: ['.coffee']
}))
.pipe(rename('podigee-podcast-player.js'))
.pipe(gulp.dest('./build/javascripts'))
.pipe(connect.reload())
})
gulp.task('html', function() {
gulp.src(paths.html)
.pipe(gulp.dest('./build'))
.pipe(connect.reload())
})
gulp.task('images', function() {
gulp.src(paths.images)
.pipe(gulp.dest('./build/images'))
.pipe(connect.reload())
})
gulp.task('fonts', function() {
gulp.src(paths.fonts)
.pipe(gulp.dest('./build/fonts'))
.pipe(connect.reload())
})
gulp.task('themes', function() {
gulp.src(paths.themes.html)
.pipe(gulp.dest('./build/themes'))
.pipe(connect.reload())
gulp.src(paths.themes.css)
.pipe(sass({style: 'compressed'}))
.pipe(gulp.dest('./build/themes'))
.pipe(connect.reload())
})
gulp.task('default', [
'stylesheets',
'javascripts',
'html',
'images',
'fonts',
'themes'
])
gulp.task('watch', function() {
gulp.watch(paths.stylesheets, ['stylesheets-dev'])
gulp.watch(paths.javascripts, ['javascripts-dev'])
gulp.watch(paths.html, ['html'])
gulp.watch(paths.images, ['images'])
gulp.watch(paths.themes.html, ['themes'])
gulp.watch(paths.themes.css, ['themes'])
})
gulp.task('connect', function() {
connect.server({
host: '0.0.0.0',
root: [__dirname],
livereload: true
});
});
gulp.task('upload', ['default'], function() {
awsCredentials = JSON.parse(fs.readFileSync('./aws.json'))
return gulp.src('build/**')
.pipe(s3(awsCredentials, {
uploadPath: "/podcast-player/",
headers: {'x-amz-acl': 'public-read'}
}))
})
gulp.task('deploy', ['upload'])
// Serve
gulp.task('serve', ['connect', 'watch']);