-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
executable file
·100 lines (90 loc) · 2.76 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
var gulp = require('gulp')
var injectPartials = require('gulp-inject-partials')
var sass = require('gulp-sass')
var postcss = require('gulp-postcss')
var flexibility = require('postcss-flexibility')
var flexBugsFixes = require('postcss-flexbugs-fixes')
var cleanCSS = require('gulp-clean-css')
var minify = require('gulp-minify')
var watch = require('gulp-watch')
var clean = require('gulp-clean')
var autoprefixer = require('gulp-autoprefixer')
var purge = require('gulp-css-purge')
var livereload = require('gulp-livereload')
var connect = require('gulp-connect')
var rename = require('gulp-rename')
gulp.task('connect', function() {
connect.server({
root: './dist',
livereload: true,
port: 8888
});
});
gulp.task('clean', function () {
return gulp
.src('./dist', {
allowEmpty: true
})
.pipe(clean());
})
gulp.task('copy-static', function () {
return gulp
.src(['./src/**/*', '!./src/scss/**/*', '!./src/html/**/*', '!./src/*.html'], { nodir: true })
.pipe(gulp.dest('./dist'))
})
gulp.task('watch:copy-static', function () {
return gulp.watch(['./src/**/*', '!./src/scss/**/*', '!./src/html/**/*', '!./src/*.html'], gulp.series('copy-static'));
});
gulp.task('scss', function () {
return gulp
.src('./src/scss/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer({
browsers: [
'last 30 versions',
'iOS >= 8',
'Safari >= 8',
'Android >= 4'
],
cascade: true
}))
.pipe(gulp.dest('./dist/css'))
})
gulp.task('scss:minify', function () {
return gulp
.src('./src/scss/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(autoprefixer({
browsers: [
'last 30 versions',
'iOS >= 8',
'Safari >= 8',
'Android >= 4'
],
cascade: true
}))
.pipe(postcss([flexibility, flexBugsFixes]))
.pipe(cleanCSS())
.pipe(rename({suffix: ".min"}))
.pipe(gulp.dest('./dist/css'))
})
gulp.task('html', function () {
return gulp
.src('./src/*.html')
.pipe(
injectPartials({
start: '<Inject src="{{path}}">',
end: '</Inject>',
removeTags: true
})
)
.pipe(gulp.dest('./dist'))
})
gulp.task('watch:html', function () {
return gulp.watch('src/**/*.html', gulp.series('html'))
})
gulp.task('watch:scss', function () {
return gulp.watch('src/scss/**/*.scss', gulp.series(['scss', 'scss:minify']))
})
gulp.task('build', gulp.series('clean','copy-static', 'html', ['scss', 'scss:minify']))
gulp.task('default', gulp.series('clean', 'copy-static', 'html', ['scss', 'scss:minify'], gulp.parallel('watch:html', 'watch:scss', 'watch:copy-static')))