-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
80 lines (66 loc) · 1.96 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
var gulp = require('gulp');
var babel = require('gulp-babel');
var sourcemaps = require('gulp-sourcemaps');
var connect = require('gulp-connect');
var htmlreplace = require('gulp-html-replace');
function babelFactory (src, dst) {
return function() {
return gulp.src(src)
.pipe(sourcemaps.init())
.pipe(babel({
presets: ['es2015']
}))
.on('error', function(error) {
console.log('error!');
console.log(error.message);
this.emit('end');
})
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest(dst))
.pipe(connect.reload());
}
}
function buildFactory (dst) {
return function() {
gulp.src(['node_modules/ohm-js/dist/ohm.js'])
.pipe(gulp.dest(dst + '/scripts'));
gulp.src(['dst/*.js'])
.pipe(gulp.dest(dst + '/scripts'));
gulp.src(['assets/**/*'])
.pipe(gulp.dest(dst + '/assets'));
};
}
// ohm-konnakkol
gulp.task('babel', babelFactory(['src/*.js'], 'dst'));
gulp.task('connect', function() {
connect.server({ livereload: true });
});
gulp.task('watchjs', function() {
gulp.watch(['index.html', 'src/*.js', 'assets/*.ohm'], ['babel']);
});
// chrome extension
gulp.task('chrome-build', ['babel'], buildFactory('chrome/extension'));
gulp.task('chrome-babel',
babelFactory(['chrome/src/*.js'], 'chrome/extension/scripts'));
gulp.task('chrome-watch', ['connect'], function() {
gulp.watch(['index.html', 'src/*.js', 'assets/*.ohm', 'chrome/src/*.js'],
['babel', 'chrome-build', 'chrome-babel']);
});
gulp.task('web', ['babel'], function() {
var dst = '/Users/ac/sites/arthurcarabott.com/konnakkol';
buildFactory(dst)();
gulp.src(['index.html'])
.pipe(htmlreplace({
js: [
'scripts/ohm.js',
'scripts/audio.js',
'scripts/konnakkol.js',
'scripts/konnakkol-editor.js',
'scripts/app.js',
'scripts/examples.js'
]
}))
.pipe(gulp.dest(dst));
});
// default
gulp.task('default', ['watchjs', 'connect']);