-
Notifications
You must be signed in to change notification settings - Fork 69
/
gulpfile.js
48 lines (43 loc) · 1.31 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
const gulp = require('gulp');
const babel = require('gulp-babel');
const concat = require('gulp-concat');
const concatCss = require('gulp-concat-css');
const rename = require('gulp-rename');
const uglify = require('gulp-uglify');
const cssNano = require('gulp-cssnano');
// Concatenate & Minify src and dependencies
gulp.task('scripts', function() {
return gulp.src([
'src/js/L.CanvasLayer.js',
'src/js/windy.js',
'src/js/L.Control.WindPosition.js',
'src/js/wind-js-leaflet.js'
])
.pipe(concat('wind-js-leaflet.js'))
.pipe(babel({
presets: ['es2015']
}))
.pipe(gulp.dest('dist'))
.pipe(rename('wind-js-leaflet.min.js'))
.pipe(uglify())
.pipe(gulp.dest('dist'));
});
gulp.task('concatCss', function () {
return gulp.src('./src/css/*.css')
.pipe(concatCss('wind-js-leaflet.css'))
.pipe(gulp.dest('./dist'));
});
gulp.task('cssNano', ['concatCss'], function() {
gulp.src('./dist/wind-js-leaflet.css')
.pipe(cssNano())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('./dist'));
});
// Default Task
gulp.task('default', ['scripts', 'concatCss', 'cssNano', 'watch']);
// Watch Files For Changes
gulp.task('watch', function() {
// We watch both JS and HTML files.
gulp.watch('src/js/*.js', ['scripts']);
gulp.watch('src/css/*.css', ['concatCss', 'cssNano']);
});