This repository has been archived by the owner on Jun 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
89 lines (74 loc) · 2.23 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
// gulp itself
var gulp = require('gulp');
// sftp
var sftp = require('gulp-sftp');
// wiredep
var wiredep = require('wiredep').stream;
var mainBowerFiles = require('main-bower-files');
// gulp-handlebars
var handlebars = require('gulp-handlebars');
var wrap = require('gulp-wrap');
var declare = require('gulp-declare');
var concat = require('gulp-concat');
// BrowserSync
var browserSync = require('browser-sync');
var reload = browserSync.reload;
// Variables
var bc = "bower_components/"
var dest = "dest";
var files = ["*.html", "css/*.css", "js/*.js"].concat(mainBowerFiles());
var fonts = [ bc + "bootstrap/dist/fonts/*", bc + "font-awesome/fonts/fontawesome-webfont.*", bc + "fullcalendar/dist/locale/de.js", "img/*" ];
// default
gulp.task('default', ['fonts', 'templates'], function() {
gulp.src(files, {base: '.'})
.pipe(wiredep())
.pipe(gulp.dest(dest));
});
// copy fonts
gulp.task('fonts', function(){
gulp.src(fonts, {base: '.'})
.pipe(gulp.dest(dest));
})
// 99% https://github.com/lazd/gulp-handlebars#gulpfilejs
gulp.task('templates', function(){
gulp.src('templates/*.hbs')
.pipe(handlebars())
.pipe(wrap('Handlebars.template(<%= contents %>)'))
.pipe(declare({
namespace: 'Templates',
noRedeclare: true, // Avoid duplicate declarations
}))
.pipe(concat('templates.js'))
.pipe(gulp.dest(dest, { base: '.' }));
});
// BrowserSync; Watch files for changes and reload
gulp.task('serve', ["default"], function() {
browserSync({
server: {
baseDir: dest
}
});
gulp.watch([files].concat(['templates/*.hbs']), {cwd: "."}, ["reload"]);
});
// Reload BrowerSync browsers
gulp.task('reload', ["default"], function() {
reload();
});
// Publish to production
gulp.task('produce', ['default'], function(){
return gulp.src(['./dest/**/*', './dest/**/.htaccess'])
.pipe(sftp({
host: 'joinout.de',
user: 'joinou',
remotePath: '/public_html/joinoutDE/studienplan5'
}))
});
// Publish to staging
gulp.task('stage', ['default'], function(){
return gulp.src(['./dest/**/*', './dest/**/.htaccess'])
.pipe(sftp({
host: 'joinout.de',
user: 'joinou',
remotePath: '/public_html/joinoutDE/studienplan5/staging'
}))
});