-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
65 lines (58 loc) · 1.78 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
var gulp = require('gulp');
//npm install --save-dev gulp-concat gulp-clean gulp-uglify gulp-zip gulp-minify-css gulp-imagemin
var concat = require('gulp-concat'),
clean = require('gulp-clean'),
uglify = require('gulp-uglify'),
zip = require('gulp-zip'),
minifyCSS = require('gulp-minify-css'),
imagemin = require('gulp-imagemin');
var paths = {
build:'build',
zipdir:'release',
zipfile:'eyetraffic.zip',
scripts: 'src/**/*.js',
images: 'src/images/**/*',
css: 'src/**/*.css',
data:['src/_locales/**/*'],
tpl:['templates/**/*']
};
gulp.task('clean', function() {
return gulp.src([paths.build], {read: false})
.pipe(clean());
});
gulp.task('scripts', function() {
// Minify and copy all JavaScript (except vendor scripts)
return gulp.src(paths.scripts)
.pipe(uglify())
.pipe(concat('all.min.js'))
.pipe(gulp.dest(paths.build));
});
//Copy all static images
gulp.task('images', function() {
return gulp.src(paths.images, { base: './' })
// Pass in options to the task
.pipe(imagemin({optimizationLevel: 5}))
.pipe(gulp.dest(paths.build));
});
gulp.task('minify-css', function() {
gulp.src(paths.css)
.pipe(minifyCSS({}))
.pipe(concat('all.min.css'))
.pipe(gulp.dest(paths.build))
});
//Copy all JSON resources
gulp.task('locale', function() {
return gulp.src(paths.data, { base: './' })
.pipe(gulp.dest(paths.build));
});
//Copy manifest.json
gulp.task('templates', function() {
return gulp.src(paths.tpl)
.pipe(gulp.dest(paths.build));
});
gulp.task('zip', function() {
return gulp.src(paths.build+'/**/*')
.pipe(zip(paths.zipfile))
.pipe(gulp.dest(paths.zipdir));
});
gulp.task('default', ['scripts', 'minify-css', 'images', 'locale', 'templates', 'zip']);