forked from Turbo87/leaflet-sidebar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
111 lines (96 loc) · 2.74 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
104
105
106
107
108
109
110
111
var gulp = require('gulp');
var clean = require('gulp-clean');
var concat = require('gulp-concat');
var csslint = require('gulp-csslint');
var header = require('gulp-header');
var jshint = require('gulp-jshint');
var minifyCSS = require('gulp-minify-css');
var sass = require('gulp-sass');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var zip = require('gulp-zip');
var pkg = require('./package.json');
var basename = pkg.name + '-' + pkg.version;
var banner = '/*! {{ pkg.name }} v{{ pkg.version }} */';
// SASS compilation
gulp.task('sass', function () {
gulp.src('./src/*.scss')
.pipe(sass())
.pipe(gulp.dest('./src'));
});
// Lint JS + CSS
gulp.task('lint', ['lint:js', 'lint:css']);
gulp.task('lint:js', function() {
return gulp.src('./src/*.js')
.pipe(jshint())
.pipe(jshint.reporter());
});
gulp.task('lint:css', ['sass'], function() {
return gulp.src('./src/*.css')
.pipe(csslint({
'adjoining-classes': false,
'box-sizing': false,
'fallback-colors': false
}))
.pipe(csslint.reporter());
});
// Concat JS + CSS
gulp.task('concat', ['concat:js', 'concat:css']);
gulp.task('concat:js', function() {
return gulp.src('./src/*.js')
.pipe(concat(basename +'.js'))
.pipe(gulp.dest('./dist'));
});
gulp.task('concat:css', ['sass'], function() {
return gulp.src('./src/*.css')
.pipe(concat(basename +'.css'))
.pipe(gulp.dest('./dist'));
});
// Minify JS + CSS
gulp.task('minify', ['minify:js', 'minify:css']);
gulp.task('minify:js', ['concat:js'], function() {
return gulp.src('./dist/' + basename + '.js')
.pipe(rename(basename + '.min.js'))
.pipe(uglify())
.pipe(header(banner, { pkg : pkg } ))
.pipe(gulp.dest('./dist'));
});
gulp.task('minify:css', ['concat:css'], function() {
return gulp.src('./dist/' + basename + '.css')
.pipe(rename(basename + '.min.css'))
.pipe(minifyCSS())
.pipe(header(banner, { pkg : pkg } ))
.pipe(gulp.dest('./dist'));
});
// Package for distribution
gulp.task('zip', ['minify'], function() {
return gulp.src([
'README.md',
'LICENSE',
'dist/' + basename + '.js',
'dist/' + basename + '.min.js',
'dist/' + basename + '.css',
'dist/' + basename + '.min.css',
])
.pipe(rename(function (dir, base, ext) {
return (dir == 'dist' ? '../' : '') + base + ext;
}))
.pipe(zip(basename + '.zip'))
.pipe(gulp.dest('dist'));
});
// Cleanup
gulp.task('clean', function() {
return gulp.src('./dist', {read: false})
.pipe(clean());
});
// Watch JS + CSS Files
gulp.task('watch', function(){
gulp.run('lint');
gulp.watch(['./src/*.js', './src/*.css'], function(event){
gulp.run('lint');
});
});
// Default
gulp.task('default', function(){
gulp.run('lint', 'minify');
});