forked from fians/Waves
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
64 lines (57 loc) · 1.45 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
/**
* Gulp build file
*/
var gulp = require('gulp');
var plumber = require('gulp-plumber');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var minifyCSS = require('gulp-minify-css');
var sourcemaps = require('gulp-sourcemaps');
var jshint = require('gulp-jshint');
var path = {
css: {
src: 'src/css/*.css',
files: 'src/css/**/*.css',
dest: './dist/'
},
js: {
src: ['src/js/*.js'],
files: 'src/js/**/*.js',
dest: './dist/'
}
}
gulp.task('cssmin', function(){
return gulp.src(path.css.src)
.pipe(plumber(function(err){
console.log(err.message);
this.emit('end'); // https://github.com/floatdrop/gulp-plumber/issues/8#issuecomment-41465386
}))
.pipe(gulp.dest(path.css.dest))
.pipe(concat('waves.min.css'))
.pipe(minifyCSS())
.pipe(gulp.dest(path.css.dest));
});
gulp.task('uglify', function(){
return gulp.src(path.js.src)
.pipe(plumber(function(err){
console.log(err.message);
this.emit('end');
}))
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(sourcemaps.init())
.pipe(gulp.dest(path.js.dest))
.pipe(concat('./waves.min.js'))
.pipe(uglify({
preserveComments: 'some'
}))
.pipe(sourcemaps.write('./', {
includeContent: false
}))
.pipe(gulp.dest(path.js.dest));
});
gulp.task('watch', function(){
gulp.watch(path.css.files, ['cssmin']);
gulp.watch(path.js.files, ['uglify']);
});
gulp.task('default', ['cssmin', 'uglify', 'watch']);