-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGulpfile.js
executable file
·36 lines (29 loc) · 1.05 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
var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var imagemin = require('gulp-imagemin');
var sourcemaps = require('gulp-sourcemaps');
var del = require('del');
var paths = {
scripts: ['public/javascripts/*.js'],
images: 'public/images/**/*'
};
gulp.task('clean', function(cb) {
del(['build'], cb);
});
gulp.task('scripts', ['clean'], function() {
return gulp.src(paths.scripts).pipe(sourcemaps.init())
.pipe(uglify())
.pipe(concat('all.min.js'))
.pipe(sourcemaps.write())
.pipe(gulp.dest('build/js'));
});
gulp.task('images', ['clean'], function() {
return gulp.src(paths.images).pipe(imagemin({optimizationLevel: 5}))
.pipe(gulp.dest('build/img'));
});
gulp.task('watch', function() {
gulp.watch(paths.scripts, ['scripts']);
gulp.watch(paths.images, ['images']);
});
gulp.task('default', ['watch', 'scripts', 'images']);