-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
118 lines (94 loc) · 2.8 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
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')
;
//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"));
});
//css
gulp.task('css',function(){
gulp.src('lib/css/style.css')
.pipe(connect.reload())
.pipe(notify("Change styles"));
});
//js
gulp.task('js', function() {
gulp.src('./lib/js/**/*.js')
.pipe(connect.reload());
});
//compress pic
gulp.task('compress-image', function () {
gulp.src('./lib/**')
.pipe(imageminJpegtran({progressive: true})())
.pipe(imageminPngquant({quality: '65-80', speed: 4})())
.pipe(gulp.dest('./lib/'));
});
//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'
])
.pipe(concat('app.min.js'))
.pipe(uglify())
.pipe(gulp.dest('./lib/js/'));
});
//watch
gulp.task('watch', function () {
gulp.watch('./index.html', ['html']);
gulp.watch('./lib/sass/**/*', ['sass']);
gulp.watch('./lib/css/**.css', ['css']);
gulp.watch('./lib/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('./lib/css/'));
});
//compress js
//gulp.task('compress-js', function() {
// gulp.src('./public/js/*')
// .pipe(uglify())
// .pipe(gulp.dest('./public/js/'))
//});
gulp.task('build-static', ['sass', 'css', 'js', 'concat-js']);
gulp.task('default', ['server', 'html', 'build-static', 'watch']);
gulp.task('production', ['build-static', 'compress-css', 'compress-image']);