-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
196 lines (158 loc) · 5.2 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
var gulp = require('gulp');
//var del = require('del');
//var critical = require('critical').stream;
var pngquant = require('imagemin-pngquant');
var imageminJpegRecompress = require('imagemin-jpeg-recompress');
var gutil = require('gulp-util');
var sassLint = require('gulp-sass-lint');
//var revReplace = require('gulp-rev-replace');
var $ = require('gulp-load-plugins')({lazy: true});
//lint task
//function isFixed(file) {
// return file.eslint != null && file.eslint.fixed;
//}
//gulp.task('jslint',['clean'], function(){
// return gulp
// .src(['./src/js/**/*.js', '!./src/js/googleanalytics.js','!./src/js/svg4everybody.js','!./src/js/mouseflow.js', '!./src/js/tawk.js','!./src/js/animation.js','!./src/js/cookie.js','!./src/js/scripts.js'])
// .pipe($.eslint({fix:true}))
// .pipe($.eslint.format())
// .pipe($.if(isFixed, gulp.dest('./src/js/fixtures')))
// .pipe($.eslint.failAfterError())
//})
gulp.task("sasslint", function(){
return gulp
.src(['./sass/**/*.scss'])
.pipe(sassLint( {options:{
configFile: './sass-lint.yml',
}}))
.pipe(sassLint.format())
.pipe(sassLint.failOnError())
});
//compile css - pug
gulp.task('css', ['sasslint'], function(){
return gulp
.src('./sass/styles.scss')
.pipe($.sass())
.pipe($.autoprefixer({
browsers: ['ie >= 11', 'last 2 versions', 'last 2 versions'],
cascade: false
}))
.pipe($.csso())
.pipe(gulp.dest('./css/'))
});
// js script concatenatetion on html files
//gulp.task('compiled',['css'], function(){
// var jsFilter = $.filter("**/*.js", { restore: true });
// var cssFilter = $.filter("**/*.css", { restore: true });
// var indexHtmlFilter = $.filter(['**/*', '!**/*.html'], { restore: true });
// return gulp.src('./src/**/*.html')
// .pipe($.useref()) // Concatenate with gulp-useref
// .pipe(jsFilter)
// .pipe($.uglify())
// .pipe(jsFilter.restore)
// .pipe(cssFilter)
// .pipe($.csso()) // Minify any CSS sources
// .pipe(cssFilter.restore)
// .pipe(indexHtmlFilter)
// .pipe($.rev()) // Rename the concatenated files (but not index.html)
// .pipe(indexHtmlFilter.restore)
// .pipe(revReplace()) // Substitute in new filenames
// .pipe(gulp.dest('./build/'));
//});
// google css on top
//gulp.task('critical',['compiled'], function(){
// gulp.task('critical', function () {
// return gulp.src('build/**/*.html')
// .pipe(critical({
// base: 'build/',
// inline: true,
// minify:true,
// ignore: ['@font-face','@import'],
// timeout: 60000,
// css: './src/css/styles.css'})
// )
// .on('error', function(err) { gutil.log(gutil.colors.red(err.message)); })
// .pipe(gulp.dest('build'));
//});
//});
//minify html
//image task
gulp.task('svgoptim', function(){
return gulp.src('./src/images/**/*.svg')
.pipe($.svgmin())
.pipe(gulp.dest('./build/images/'));
});
gulp.task('retina', function(){
return gulp.src('./images/**/*.{jpg,png}')
.pipe($.responsive({
// Resize all JPG images to three different sizes: 100, 200, and 400, 800 pixels
'**/*.jpg': [{
width: 600,
rename: { suffix: 'phone_2x' },
quality: 100
}, {
width: 960,
rename: { suffix: 'phone-land_2x' },
}, {
width: 1536,
rename: { suffix: 'tablet_2x' },
}, {
width: 1920,
rename: { suffix: '' },
},{
width: 2880,
rename: { suffix: '_2x' },
},{
// Compress, strip metadata, and rename original image
rename: { suffix: '-original' },
}],
// Resize all PNG images to be retina ready
// '**/*.png': [{
// width: 72,
// rename: { suffix:'_thumb'}
// }, {
// width: 144,
// rename: { suffix: '_thumb_2x' }
// },
// {
// width: 580,
// },{
// width: 1160,
// rename:{ suffix:'_2x'}
//
// }],
// },
// {
//
// withMetadata: false,
// progressive: false,
// withoutEnlargement: true,
// quality: 100,
// toColourspace: 'rgb',
// ChromaSubsampling:'4:2:2',
// errorOnEnlargement: false,
}))
.pipe(gulp.dest('./images/final/'));
});
gulp.task('png', ['retina'], function(){
return gulp.src('./images/*.png')
.pipe($.imagemin({
progressive: true,
verbose: true,
quality:68,
use: [pngquant()]
}))
.pipe(gulp.dest('./images/final/'));
});
// gulp.task('image-optim', ['clientsprite'], function(){
// return gulp.src('./src/images/optim/**/*.jpg')
// .pipe($.imagemin([
// imageminJpegRecompress({
// verbose: true,
// progressive: true,
// max: 80,
// min: 70
// })
// ]))
// .pipe(gulp.dest('./build/images/'));
// });