-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
83 lines (62 loc) · 1.45 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
'use strict'
let
ugly = require('gulp-uglify')
,gulp = require('gulp')
,watch = require('gulp-watch')
,plumber = require('gulp-plumber')
,newer = require('gulp-newer')
,stylus = require('gulp-stylus')
,concat = require('gulp-concat')
,rename = require('gulp-rename')
,runSequence = require('run-sequence')
,_ = require('lodash')
,path = require('path')
,fs = require('fs')
let
cssFolder = __dirname + '/public/css'
,jsFolder = __dirname + '/public/js'
,stylusOptions = {
compress: true
}
,uglyOptions = {
}
gulp.task('stylus', function() {
gulp.src(cssFolder + '/*.styl')
// .pipe(newer({
// dest: cssFolder
// ,map: function(path) {
// return path.replace(/\.styl$/, '.css')
// }
// }))
.pipe(plumber())
.pipe(stylus(stylusOptions))
.pipe(gulp.dest(cssFolder))
})
gulp.task('ugly', function() {
gulp.src(jsFolder + '/*.js')
.pipe(newer({
dest: jsFolder
,map: function(path) {
return path.replace(/\.dev.js$/, '.min.js')
}
}))
.pipe(plumber())
.pipe(rename(function (path) {
path.basename = path.basename.replace('.dev', '.min')
}))
.pipe(gulp.dest(jsFolder))
.pipe(ugly(uglyOptions))
.pipe(gulp.dest(jsFolder))
})
gulp.task('watch', function () {
watch([cssFolder + '/*.styl', cssFolder + '/parts/*.styl'], function() {
runSequence('stylus')
})
watch(jsFolder, function() {
runSequence('ugly')
})
})
gulp.task('default', ['watch'])
gulp.task('dist', function() {
runSequence('stylus', 'ugly')
})