-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
103 lines (74 loc) · 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
// Declare variables
var gulp = require('gulp'),
wiredep = require('wiredep').stream;
useref = require('gulp-useref'),
gulpif = require('gulp-if'),
clean = require('gulp-clean'),
sass = require('gulp-sass'),
mmq = require('gulp-merge-media-queries'),
uglify = require('gulp-uglify'),
minifycss = require('gulp-minify-css'),
imagemin = require('gulp-imagemin'),
plumber = require('gulp-plumber'),
pngquant = require('imagemin-pngquant'),
livereload = require('gulp-livereload');
// Bower
gulp.task('bower', function () {
gulp.src('app/index.html')
.pipe(wiredep({
directory: "bower_components"
}))
.pipe(gulp.dest('app/'));
});
// Image Optimization
gulp.task('imagemin', function() {
gulp.src('app/img/**/*')
.pipe(imagemin({
progressive: true,
svgoPlugins: [{removeViewBox: false}],
use: [pngquant()]
}))
.pipe(gulp.dest('app/build/img'));
});
// Merge media queries
gulp.task('mmq', function () {
gulp.src('app/**/*.css')
.pipe(mmq({
log: true
}))
.pipe(gulp.dest('app/**/*.css'));
});
// Clean
gulp.task('clean', function () {
gulp.src('app/build/*.*', {read: false})
.pipe(clean());
});
// Build
gulp.task('build', ['imagemin', 'clean'], function () {
var assets = useref.assets();
gulp.src('app/*.html')
.pipe(assets)
// .pipe(gulpif('*.js', uglify()))
.pipe(gulpif('*.css', mmq()))
// .pipe(gulpif('*.css', minifycss()))
.pipe(assets.restore())
.pipe(useref())
.pipe(gulp.dest('app/build'));
});
// Sass
gulp.task('sass', function () {
gulp.src('app/css/*.scss')
.pipe(plumber())
.pipe(sass({outputStyle: 'compact'})) // expanded, compact, compressed options available
.pipe(gulp.dest('app/css/'))
// .pipe(cmq())
.pipe(livereload());
});
// Watch task
gulp.task('watch', function () {
var server = livereload();
gulp.watch('bower.json', ['bower']);
gulp.watch('app/css/*.scss', ['sass']);
})
// Default task
gulp.task('default', ['watch']);