-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
109 lines (94 loc) · 2.95 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
var gulp = require('gulp');
var sass = require('gulp-sass');
var coffee = require('gulp-coffee');
var rename = require('gulp-rename');
var concat = require('gulp-concat');
var inlinesource = require('gulp-inline-source');
var browserSync = require('browser-sync').create();
var reload = browserSync.reload;
var deployDest = '../leseübung-gh-pages';
var exec = require('child_process').exec;
var src = {
html: 'app/*.html',
scss: 'app/scss/**/*.scss',
coffee: 'app/coffeescript/**/*.coffee',
javascript: 'app/javascript/*.js'
}
gulp.task('sass', function() {
return gulp.src(src.scss, { sourcemaps: true })
.pipe(sass())
.pipe(gulp.dest('build/app/styles/'))
.pipe(reload({ stream:true }));
});
gulp.task('coffee', function() {
gulp.src('app/coffeescript/**/*.coffee', { sourcemaps: true })
.pipe(coffee({bare: true}))
.pipe(concat('main.js'))
.pipe(gulp.dest('build/app/scripts/'))
.pipe(reload({ stream:true }));
});
gulp.task('javascript', function() {
gulp.src('app/javascript/*')
.pipe(gulp.dest('build/app/scripts'))
});
gulp.task('vendor', function() {
gulp.src('vendor/scripts/*')
.pipe(gulp.dest('build/app/scripts/vendor'))
});
gulp.task('html', function(){
gulp.src(src.html)
.pipe(gulp.dest('build/app/'))
});
// watch files for changes and reload
gulp.task('serve', ['html', 'assets'], function() {
browserSync.init({
server: {
baseDir: 'build/app/'
}
});
// watch Sass files for changes, run the Sass preprocessor with the 'sass' task and reload
gulp.watch(src.scss, ['sass']);
gulp.watch(src.coffee, ['coffee']);
gulp.watch(src.javascript, ['javascript']);
gulp.watch(src.html, ['html']).on('change', reload)
});
gulp.task('assets', ['vendor', 'coffee', 'javascript', 'sass']);
gulp.task('app', ['html', 'assets']);
gulp.task('standalone', ['app'], function() {
gulp.src('build/app/index.html')
.pipe(inlinesource({
rootpath: 'build/app/'
}))
.pipe(rename('standalone.html'))
.pipe(gulp.dest('build/'));
gulp.src('build/app/index.en.html')
.pipe(inlinesource({
rootpath: 'build/app/'
}))
.pipe(rename('standalone.en.html'))
.pipe(gulp.dest('build/'));
gulp.src('build/app/metronome.html')
.pipe(inlinesource({
rootpath: 'build/app/'
}))
.pipe(rename('metronome.html'))
.pipe(gulp.dest('build/'));
});
gulp.task('build', ['app', 'standalone']);
gulp.task('default', ['serve']);
gulp.task('deploy', ['build'], function(){
gulp.src('build/**/*', { base: 'build/' })
.pipe(gulp.dest(deployDest))
gulp.src('README.md')
.pipe(rename('index.md'))
.pipe(gulp.dest(deployDest))
gulp.src('doc/**/*')
.pipe(gulp.dest(deployDest + "/doc"))
});
gulp.task('test', [], function(cb){
exec("coffee -r '../app/coffeescript/lib/normalize_bar_string.coffee' test/normalizer_test.coffee", function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
});