-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
86 lines (78 loc) · 2.11 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
var gulp = require('gulp'),
gutil = require('gulp-util'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
header = require('gulp-header'),
artoo = require('gulp-artoo'),
jshint = require('gulp-jshint'),
webserver = require('gulp-webserver');
// Files
var files = [
'./src/sabretache.js',
'./src/sabretache.readability.js',
'./src/plugins/*.js'
];
// Linting
gulp.task('lint', function() {
return gulp.src(files)
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
// Building the files
gulp.task('build', function() {
return gulp.src(files)
.pipe(concat('sabretache.concat.js'))
.pipe(gulp.dest('./build'))
.pipe(uglify().on('error', gutil.log))
.pipe(rename('sabretache.min.js'))
.pipe(gulp.dest('./build'));
});
// Building test bookmarklets
gulp.task('bookmarklets', function() {
artoo.blank('sabretache.footprint.bookmark.js')
.pipe(artoo({
version: 'edge',
settings: {
scriptUrl: 'https://localhost:8000/test/bookmarklets/footprint_test.js',
dependencies: [
{
name: 'sabretache',
globals: 'sabretache',
url: 'https://localhost:8000/build/sabretache.concat.js'
}
]
}
}))
.pipe(gulp.dest('./build/bookmarklets'));
artoo.blank('sabretache.readability.bookmark.js')
.pipe(artoo({
version: 'edge',
settings: {
scriptUrl: 'https://localhost:8000/test/bookmarklets/readability_test.js',
dependencies: [
{
name: 'sabretache',
globals: 'sabretache',
url: 'https://localhost:8000/build/sabretache.concat.js'
}
]
}
}))
.pipe(gulp.dest('./build/bookmarklets'));
});
// Watching
gulp.task('watch', function() {
gulp.watch(files, ['build']);
});
// Server
gulp.task('serve', function() {
return gulp.src('./')
.pipe(webserver({
directoryListing: true,
https: true
}));
});
// Macro-tasks
gulp.task('default', ['lint', 'build', 'bookmarklets']);
gulp.task('work', ['build', 'serve', 'watch']);