-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
140 lines (117 loc) · 3.7 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
var gulp = require('gulp')
, notify = require("gulp-notify")
, csso = require('gulp-csso')
, uglify = require('gulp-uglify')
, connect = require('gulp-connect')
, compass = require('gulp-for-compass')
, concat = require('gulp-concat')
, autoprefixer = require('gulp-autoprefixer')
, imageminJpegtran = require('imagemin-jpegtran')
, imageminPngquant = require('imagemin-pngquant')
, imageResize = require('gulp-image-resize')
;
//server
gulp.task('server', function() {
connect.server({
livereload: true
});
});
//html
gulp.task('html',function(){
gulp.src('index.html')
.pipe(connect.reload())
.pipe(notify("Change index.html"));
gulp.src('sponsors.html')
.pipe(connect.reload())
.pipe(notify("Change sponsors.html"));
});
//css
gulp.task('css',function(){
gulp.src('style.css')
.pipe(connect.reload());
});
//js
gulp.task('js', function() {
gulp.src('./lib/js/**/*.js')
.pipe(connect.reload());
});
//compress pic
gulp.task('compress-image', function () {
gulp.src('./lib/**.jpg')
.pipe(imageminJpegtran({progressive: true})())
.pipe(gulp.dest('./build/lib/'));
gulp.src('./lib/pic/**')
.pipe(imageResize({ width : 1280 }))
.pipe(gulp.dest('./build/lib/pic/'));
gulp.src('./lib/image/**/*.{png,jpg}')
.pipe(imageResize({ width : 300 }))
.pipe(imageminJpegtran({progressive: true})())
.pipe(imageminPngquant({quality: '65-80', speed: 4})())
.pipe(gulp.dest('./build/lib/image/'));
gulp.src('./lib/image/**/*.svg')
.pipe(gulp.dest('./build/lib/image/'));
});
//sass
gulp.task('sass', function(){
gulp.src('./lib/sass/**/*.sass')
.pipe(compass({
httpFontsPath: '../font/',
httpGeneratedImagesPath: '../pic/',
cssDir: './lib/css/',
sassDir: './lib/sass/',
fontsDir: './lib/font/',
imagesDir: './lib/pic/',
force: true
}))
.pipe(connect.reload())
.pipe(notify("Compile SASS"));
});
//concat
gulp.task('concat-js', function() {
return gulp.src([
'./lib/js/owl.carousel.js',
//'./lib/js/jquery.stellar.js',
//'./lib/js/jquery.appear.js',
'./lib/js/app.js',
'./lib/js/map.js'
])
.pipe(concat('app.min.js'))
.pipe(uglify())
.pipe(gulp.dest('./build/lib/js/'));
});
//watch
gulp.task('watch', function () {
gulp.watch('./index.html', ['html']);
gulp.watch('./lib/sass/**/*', ['sass']);
gulp.watch('./lib/css/**/*', ['css']);
gulp.watch('./lib/js/**/*', ['concat-js', 'js']);
});
//compress css
gulp.task('compress-css', function() {
return gulp.src('./lib/css/style.css')
.pipe(autoprefixer({
browsers: ['last 10 versions'],
cascade: false
}))
.pipe(csso())
.pipe(gulp.dest('./build/lib/css/'));
});
//compress js
//gulp.task('compress-js', function() {
// gulp.src('./public/js/*')
// .pipe(uglify())
// .pipe(gulp.dest('./public/js/'))
//});
gulp.task('copy-src',['build-static', 'compress-css', 'compress-image'],function() {
gulp.src(['./*.html','./favicon.*'])
.pipe(gulp.dest('./build'))
gulp.src(['./lib/font/*'])
.pipe(gulp.dest('./build/lib/font'))
gulp.src(['./lib/css/*'])
.pipe(gulp.dest('./build/lib/css'))
gulp.src(['./lib/js/app.min.js'])
.pipe(gulp.dest('./build/lib/js'))
});
gulp.task('build-static', ['sass', 'css', 'js', 'concat-js']);
gulp.task('default', ['server', 'html', 'build-static', 'watch']);
gulp.task('production', ['build-static', 'copy-src']);