This repository was archived by the owner on Mar 4, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgulpfile.js
More file actions
93 lines (80 loc) · 2.7 KB
/
gulpfile.js
File metadata and controls
93 lines (80 loc) · 2.7 KB
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
var gulp = require('gulp'),
sass = require('gulp-sass'),
autoprefixer = require('gulp-autoprefixer'),
rename = require('gulp-rename'),
cssmin = require('gulp-cssmin'),
jshint = require('gulp-jshint'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
addsrc = require('gulp-add-src'),
order = require('gulp-order'),
watch = require('gulp-watch'),
livereload = require('gulp-livereload'),
notify = require('gulp-notify'),
connect = require('gulp-connect'),
critical = require("critical"),
htmlmin = require("gulp-htmlmin"),
imagemin = require('gulp-imagemin'),
pngcrush = require('imagemin-pngcrush'),
jpegtran = require('imagemin-jpegtran');
gulp.task('sass', function() {
gulp.src('./scss/style.scss')
.pipe(sass({
onError: function(err) {
return notify().write(err);
}
}))
.pipe(autoprefixer("last 2 version", "ie 9"))
.pipe(cssmin())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('./dist/css'));
});
gulp.task('js', function() {
gulp.src('./js/scripts.js')
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(addsrc('./js/_libs/*.js'))
.pipe(order([
'js/_libs/jquery-2.1.3.js',
'js/_libs/owl.carousel.js',
'js/scripts.js'
], { base: './' }))
.pipe(concat('scripts.min.js'))
.pipe(uglify({mangle: false}))
.pipe(gulp.dest('./dist/js'));
});
gulp.task("critical", function() {
critical.generateInline({
base: './',
src: 'index.html',
width: 320,
height: 480,
htmlTarget: 'index.critical.html',
minify: true,
});
});
gulp.task("minify-html", ["critical"], function() {
gulp.src('./index.critical.html')
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('./'));
});
gulp.task('images', function () {
return gulp.src('./img/*')
.pipe(imagemin({
svgoPlugins: [{removeViewBox: false}],
use: [pngcrush(), jpegtran()]
}))
.pipe(gulp.dest('./dist/img'));
});
gulp.task('connect', function() {
connect.server();
});
gulp.task('watch', function() {
livereload.listen();
gulp.watch('./scss/**/*.scss', ['sass']).on('change', livereload.changed);
gulp.watch('./js/**/*.js', ['js']).on('change', livereload.changed);
gulp.watch('./**/*.php').on('change', livereload.changed);
});
gulp.task('server', ['connect', 'watch']);
gulp.task('build', ['sass', 'js']);