-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
86 lines (74 loc) · 2.16 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
'use strict'
const gulp = require('gulp')
const browserSync = require('browser-sync')
const del = require('del')
const $ = require('gulp-load-plugins')()
let production = true
gulp.task('styles', function() {
return gulp.src('src/styles/*.less')
.pipe($.plumber())
.pipe($.less()
.on('error', $.util.log))
.pipe($.postcss([
require('autoprefixer-core')({
browsers: ['> 1%', 'last 2 versions']
})
]))
.pipe($.if(production, $.minifyCss()))
.pipe(gulp.dest('build/styles'))
})
gulp.task('views', ['styles', 'scripts'],function(){
return gulp.src(['src/views/*.jade'])
.pipe($.plumber())
.pipe($.jade({
pretty: !production
}))
.on('error', $.util.log)
.pipe(gulp.dest('build'))
.pipe(browserSync.reload({stream: true}))
})
gulp.task('images', function() {
return gulp.src('src/images/**/*')
.pipe($.plumber())
// .pipe($.imagemin({
// svgoPlugins: [{
// convertPathData: false
// }]
// }))
.pipe(gulp.dest('build/images'))
})
gulp.task('scripts', function() {
return gulp.src('src/scripts/*.coffee')
.pipe($.plumber())
.pipe($.coffee())
.on('error', $.util.log)
.pipe($.if(production, $.uglify()))
.pipe(gulp.dest('build/scripts'))
})
gulp.task('lib', function() {
return gulp.src('src/lib/*')
.pipe(gulp.dest('build/lib'))
})
gulp.task('browser-sync', function() {
browserSync({
server: {
baseDir: './build'
}
})
})
gulp.task('watch', ['build'], function() {
gulp.watch('src/styles/*.less', ['views'])
gulp.watch('src/views/**/*.jade', ['views'])
gulp.watch('src/scripts/*.coffee', ['views'])
gulp.start('browser-sync')
})
gulp.task('clean', function(cb) {
del(['build'], cb)
})
gulp.task('build', ['views', 'images', 'lib'], function() {
production && setTimeout(()=>console.info("build complete~"), 0)
})
gulp.task('default', ['clean'], function() {
production = false
gulp.start('watch')
})