-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
50 lines (44 loc) · 1.17 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
const gulp = require('gulp')
const gutil = require('gulp-util')
const watch = require('gulp-watch')
const notify = require('gulp-notify')
const plumber = require('gulp-plumber')
const sass = require('gulp-sass')
const prefixer = require('gulp-autoprefixer')
const cssmin = require('gulp-cssmin')
const rename = require('gulp-rename')
const browserSync = require('browser-sync')
gulp.task('browser-sync', () => {
browserSync.init({
server: {
baseDir: './docs'
}
})
})
gulp.task('watch', () => {
watch('docs/**/*', (event) => {
browserSync.reload()
})
watch('src/sass/**/*.scss', (event) => {
gulp.start(['sass'])
})
})
gulp.task('sass', () => {
gulp.src('src/sass/**/*.scss')
.pipe(plumber({
errorHandler: notify.onError('Error: <%= error.message %>')
}))
.pipe(sass())
.pipe(prefixer('last 2 version'))
.pipe(gulp.dest('docs/css'))
})
gulp.task('cssmin', () => {
gulp.src('docs/css/style.css')
.pipe(plumber({
errorHandler: notify.onError('Error: <%= error.message %>')
}))
.pipe(cssmin())
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest('docs/css'))
})
gulp.task('default', ['browser-sync', 'watch'])