-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
70 lines (59 loc) · 1.67 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
var gulp = require('gulp');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var browserSync = require('browser-sync');
var del = require('del');
var imagemin = require('gulp-imagemin');
var pngquant = require('imagemin-pngquant');
var cache = require('gulp-cache');
gulp.task('sass', function() {
return gulp.src(['app/sass/**/*.sass', 'app/sass/**/*.scss'])
.pipe(sass({outputStyle: 'expanded'}).on('error', sass.logError))
.pipe(autoprefixer({
browsers: ['last 15 versions', '> 1%', 'ie 8', 'ie 7'],
cascade: false
}))
.pipe(gulp.dest('app/css'))
.pipe(browserSync.reload({stream: true}))
});
gulp.task('browser-sync', function() {
browserSync({
server: {
baseDir: 'app'
},
notify: false,
//tunnel: true,
//tunnel: "ptoj"
})
});
gulp.task('clean', function() {
return del.sync('dist');
});
gulp.task('clear', function() {
return cache.clearAll();
});
gulp.task('img', function() {
return gulp.src('app/img/**/*')
.pipe(cache(imagemin({
interlaced: true,
progressive: true,
svgoPlugins: [{removeViewBox: false}],
une: [pngquant()]
})))
.pipe(gulp.dest('dist/img'));
})
gulp.task('watch', ['browser-sync', 'sass'], function() {
gulp.watch(['app/sass/**/*.sass', 'app/sass/**/*.scss'], ['sass']);
gulp.watch('app/*html', browserSync.reload);
});
gulp.task('default', ['watch']);
gulp.task('build', ['clean', 'img', 'sass'], function() {
var buildCss = gulp.src('app/css/**/*')
.pipe(gulp.dest('dist/css'));
var buildFonts = gulp.src('app/fonts/**/*')
.pipe(gulp.dest('dist/fonts'));
var buildJs = gulp.src('app/js/**/*')
.pipe(gulp.dest('dist/js'));
var buildHtml = gulp.src('app/*.html')
.pipe(gulp.dest('dist'));
});