-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
60 lines (52 loc) · 1.53 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
const gulp = require('gulp')
const browsersync = require('browser-sync')
const pug = require('gulp-pug')
const sass = require('gulp-sass')
const autoprefixer = require('gulp-autoprefixer')
const imagemin = require('gulp-imagemin')
const pngquant = require('imagemin-pngquant')
const reload = browsersync.reload
gulp.task('imagemin', () => (
gulp.src('./src/img/**/*.{gif,jpg,png}')
.pipe(imagemin({
progressive: true,
interlaced: true,
use: [pngquant()],
}))
.pipe(gulp.dest('./dist/img'))
))
gulp.task('fonts', () => gulp.src('src/fonts/**/*')
.pipe(gulp.dest('dist/fonts')))
gulp.task('pug',() =>
gulp.src('./src/pug/*.pug')
.pipe(pug({
pretty:true
}))
.pipe(gulp.dest('./dist'))
.pipe(reload({ stream: true }))
)
gulp.task('sass', () => gulp.src('./src/styles/main.scss')
.pipe(sass({
outputStyle:'compressed',
sourceComments:false
}))
.pipe(autoprefixer({
versions:['last 2 browsers']
}))
.pipe(gulp.dest('./dist/'))
.pipe(reload({ stream: true })))
gulp.task('browsersync', () => (
browsersync({
server: {
baseDir: './dist',
},
open: false,
})
))
gulp.task('watch', () => {
gulp.watch('./src/styles/**/*.scss', ['sass'])
gulp.watch('./src/img/**/*.{gif,jpg,png}', ['imagemin'])
gulp.watch('./src/pug/**/*.pug', ['pug'])
gulp.watch('./src/fonts/**/*.*', ['fonts'])
})
gulp.task('default', ['fonts', 'imagemin', 'sass', 'pug', 'browsersync', 'watch'])