-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
83 lines (72 loc) · 2.08 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
const gulp = require('gulp')
const browserSync = require('browser-sync').create()
const sass = require('gulp-sass')(require('sass'))
const prefix = require('gulp-autoprefixer')
const plumber = require('gulp-plumber')
const cleanCSS = require('gulp-clean-css');
const htmlmin = require('gulp-htmlmin');
const terser = require('gulp-terser');
const imagemin = require('gulp-imagemin');
const liquid = require('@tuanpham-dev/gulp-liquidjs')
const reload = browserSync.reload
gulp.task('browser-sync', () => {
browserSync.init({
notify: false,
server: {
baseDir: './'
}
})
gulp.watch('./*.html').on('change', reload)
gulp.watch('./scss/*.scss').on('change', reload);
gulp.watch('./views/**/*.liquid', gulp.series('html'))
gulp.watch('./scss/**/*.scss', gulp.series('css'))
gulp.watch('./js/**/*.js', reload)
})
gulp.task('css', () => {
return gulp.src('./scss/main.scss')
.pipe(plumber([{
errorHandler: false
}]))
.pipe(sass())
.pipe(prefix())
.pipe(gulp.dest('./css/'))
.pipe(browserSync.stream())
})
gulp.task('html', () => {
return gulp.src('./views/pages/*.liquid')
.pipe(liquid({
engine: {
root: ['./views', './views/components']
}
}))
.pipe(gulp.dest('./'))
.on('end', reload)
})
gulp.task('default', gulp.series('html', 'css', 'browser-sync'))
gulp.task('dist-css', () => {
return gulp.src('./css/*.css')
.pipe(cleanCSS({level: {1: {specialComments: false}}}))
.pipe(gulp.dest('dist/css'));
})
gulp.task('dist-html', () => {
return gulp.src('./*.html')
.pipe(htmlmin({
collapseWhitespace: true
}))
.pipe(gulp.dest('dist'));
})
gulp.task('dist-js', () => {
return gulp.src('./js/*.js')
.pipe(terser())
.pipe(gulp.dest('dist/js'));
})
gulp.task('dist-img', () => {
return gulp.src('./img/*')
.pipe(imagemin())
.pipe(gulp.dest('dist/img'));
})
gulp.task('dist-data', () => {
return gulp.src('./data/*')
.pipe(gulp.dest('dist/data'));
})
gulp.task('dist', gulp.series('css', 'html', 'dist-css', 'dist-html', 'dist-js', 'dist-img', 'dist-data'));