This repository has been archived by the owner on Aug 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
120 lines (105 loc) · 3.05 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
"use strict"
const args = require('yargs').argv
const gulp = require('gulp')
const sequence = require('run-sequence')
const del = require('del')
const $ = require('gulp-load-plugins')({lazy: true})
const wiredep = require('wiredep').stream
require('sugar')
/**
* List the available gulp tasks
*/
gulp.task('help', $.taskListing)
gulp.task('default', ['serve', 'watch'])
gulp.task('serve', ['start-server'], () => {
return gulp.src(__filename)
.pipe($.open({
uri: 'http://localhost:3000'
}))
})
gulp.task('start-server', ['jade2html'], () => {
return $.connect.server({
root: ['.tmp', 'libs'],
port: 3000,
livereload: true
})
})
gulp.task('jade2html', ['styles', 'fonts'], () => {
return gulp.src(['src/**/*.jade', '!src/includes/**', '!src/templates/**', '!src//**/_*.jade'])
.pipe($.plumber({errorHandler: $.notify.onError({title: 'Jade Compiler', message: '<%= error.message %>'})})) // Important for not breaking the pipe
.pipe($.debug())
//.pipe($.cached('jade2html'))
.pipe($.data((currentFile) => require('./framework') ))
.pipe($.jade({
//debug: true,
pretty: true
}))
.pipe(wiredep({
ignorePath: '../libs'
}))
.pipe($.inject(gulp.src(['.tmp/assets/js/**/*.js', '.tmp/assets/css/**/*.css'], {read: false}), {
ignorePath: '.tmp/'
}))
.pipe(gulp.dest('.tmp/'))
.pipe($.connect.reload())
})
/**
* Compile less to css
* @return {Stream}
*/
gulp.task('styles', () => {
return gulp.src('src/assets/less/index.less')
.pipe($.plumber({errorHandler: $.notify.onError({title: 'Less Compiler', message: '<%= error.message %>'})})) // Important for not breaking the pipe
.pipe($.debug())
.pipe($.sourcemaps.init())
.pipe($.less())
//.pipe($.autoprefixer({browsers: ['last 2 version', '> 5%']}))
.pipe($.sourcemaps.write())
.pipe(gulp.dest('.tmp/assets/css'))
})
gulp.task('fonts', () => {
return gulp.src('src/assets/fonts/**/*.*')
.pipe(gulp.dest('.tmp/assets/fonts'))
})
gulp.task('liveReload', () => {
return gulp.src('.tmp/*.html')
.pipe($.connect.reload())
})
gulp.task('styles-watcher', (done) => {
sequence('styles', 'liveReload', done)
})
gulp.task('watch', () => {
gulp.watch(['src/assets/less/**/*.less'], ['styles-watcher'])
gulp.watch(['src/**/*.jade'], ['jade2html'])
})
// TODO
/**
* Bump the version
* --type=pre will bump the prerelease version *.*.*-x
* --type=patch or no flag will bump the patch version *.*.x
* --type=minor will bump the minor version *.x.*
* --type=major will bump the major version x.*.*
* --version=1.2.3 will bump to a specific version and ignore other flags
*/
/*
gulp.task('bump', () => {
const msg = 'Bumping versions'
const type = args.type
const version = args.ver
const options = {}
if (version) {
options.version = version
msg += ' to ' + version
} else {
options.type = type
msg += ' for a ' + type
}
log(msg)
return gulp
.src(config.packages)
.pipe($.print())
.pipe($.bump(options))
.pipe(gulp.dest(config.root))
})
*/
module.exports = gulp