-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
68 lines (55 loc) · 1.55 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
var gulp = require('gulp');
var livereload = require('gulp-livereload');
var serve = require('gulp-serve');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
// Static file server
gulp.task('server', serve({
root: ['example', 'dist'],
port: 7000
}));
// Task for refreshing everything (HTML, etc)
gulp.task('refresh-browser', function() {
gulp.src('package.json', {read: false})
.pipe(livereload());
});
// Files to bundle
JS_DIST_FILES = [
'libs/tracekit.js',
'src/opbeat.js'
];
// Bundles files into
gulp.task('process-scripts', function() {
gulp.src(JS_DIST_FILES)
.pipe(concat('opbeat.js'))
.pipe(gulp.dest('./dist'))
.pipe(uglify().on('error', function(e) { console.log('\x07',e.message); return this.end(); }))
.pipe(concat('opbeat.min.js'))
.pipe(gulp.dest('./dist'))
.pipe(livereload());
});
// Development mode
gulp.task('watch', [], function(cb){
// Livereload
livereload.listen();
gulp.run(
'process-scripts',
'server'
);
// Watch JS files
gulp.watch(['libs/**', 'src/**'], ['process-scripts']);
// Watch example files
gulp.watch('example/**', ['refresh-browser']);
console.log('\nExample site running on http://localhost:7000/\n');
});
//
// Default task
//
gulp.task('default', function(){
var response = ['',
'No task selected.',
'Available tasks:', '',
'gulp watch - Watch files and preview example site on localhost.', ''
].join('\n');
console.log(response);
});