-
Notifications
You must be signed in to change notification settings - Fork 72
/
gulpfile.js
103 lines (89 loc) · 2.62 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
var gulp = require('gulp');
var shell = require('gulp-shell');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var eslint = require('gulp-eslint');
var size = require('gulp-size');
var sass = require('gulp-sass');
var header = require('gulp-header');
var markdown = require('gulp-markdown');
var plumber = require('gulp-plumber');
var connect = require('gulp-connect');
// -----------------------------------------------------------------------------
// Configuration
// -----------------------------------------------------------------------------
var pkg = require('./package.json');
var paths = {
src: 'src/*.js',
dist: 'dist'
};
var banner = [
'// <%= pkg.name %> - <%= pkg.description %>',
'// @version v<%= pkg.version %>',
'// @link <%= pkg.homepage %>',
'// @license <%= pkg.license %>',
''
].join('\n');
// -----------------------------------------------------------------------------
// Assets
// -----------------------------------------------------------------------------
gulp.task('geojson', function () {
gulp.src('vendor/ne_110m_land/ne_110m_land.shp')
.pipe(shell([
'rm -f dist/world.json',
'ogr2ogr -f "GeoJSON" -lco COORDINATE_PRECISION=1 -simplify 0.4 dist/world.json <%= file.path %>'
]));
});
gulp.task('dist', function () {
return gulp.src(paths.src)
.pipe(size({ title: 'Uncompressed' }))
.pipe(gulp.dest(paths.dist))
.pipe(rename({ suffix: '.min' }))
.pipe(uglify())
.pipe(header(banner, { pkg: pkg }))
.pipe(size({ title: 'Minified' }))
.pipe(gulp.dest(paths.dist));
});
gulp.task('serve', function () {
connect.server({
port: 4500
});
});
gulp.task('docs', function () {
gulp.src('assets/style.scss')
.pipe(plumber())
.pipe(sass())
.pipe(gulp.dest('assets'));
});
// -----------------------------------------------------------------------------
// Testing
// -----------------------------------------------------------------------------
gulp.task('lint', function () {
return gulp.src('src/**/*.js')
.pipe(eslint({
rules: {
'quotes': 'single',
'no-global-strict': 0
},
globals: {
'require': true,
'module': true,
'define': true,
'exports': true
},
env: {
browser: true
}
}))
.pipe(eslint.format());
});
// -----------------------------------------------------------------------------
// Tasks
// -----------------------------------------------------------------------------
gulp.task('watch', function () {
gulp.watch('src/**/*.js', ['build']);
gulp.watch('assets/*.*', ['docs']);
});
gulp.task('test', ['lint']);
gulp.task('build', ['test', 'dist']);
gulp.task('default', ['build', 'docs', 'serve', 'watch']);