-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathgulpfile.js
68 lines (59 loc) · 1.3 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
/**
* Module dependencies
*/
var gulp = require('gulp');
var log = require('gulp-util').log;
var babel = require('gulp-babel');
var rename = require('gulp-rename');
var replace = require('gulp-replace');
var concat = require('concat-stream');
/**
* Configurations
*/
var config = {
watch: './src/*',
js: {
src: './src/index.js',
out: './build'
},
template: {
pattern: '{{bookmarkletCode}}',
src: './src/index.tpl',
out: './landing'
},
babel: {
presets: ['babili'],
plugins: ['transform-function-to-arrow'],
comments: false
}
};
/**
* Javascript task
*/
gulp.task('compile', function() {
var compiled = gulp.src(config.js.src)
.pipe(babel(config.babel));
compiled
.pipe(rename('bookmarklet.js'))
.pipe(gulp.dest(config.js.out));
compiled
.pipe(concat(function(codeBuffer) {
var code = codeBuffer[0].contents.toString();
gulp.src(config.template.src)
.pipe(replace(config.template.pattern, code))
.pipe(rename('index.html'))
.pipe(gulp.dest(config.template.out));
}));
});
/**
* Watch task
*/
gulp.task('watch', function() {
log('Watching files');
gulp.watch(config.watch, ['compile']);
});
/**
* Command line task commands
*/
gulp.task('build', ['compile']);
gulp.task('default', ['build', 'watch']);