-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
139 lines (109 loc) · 3.44 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
'use strict';
var gulp = require('gulp');
// load plugins
var $ = require('gulp-load-plugins')();
gulp.task('styles', function () {
return gulp.src('src/styles/*.scss')
.pipe($.sass({
style: 'nested'
}))
.pipe($.autoprefixer('last 1 version'))
.pipe(gulp.dest('.tmp/styles'))
.pipe($.size());
});
gulp.task('scripts', function () {
return gulp.src('src/scripts/**/*.js')
.pipe($.jshint())
.pipe($.jshint.reporter(require('jshint-stylish')))
.pipe($.size());
});
gulp.task('html', ['styles', 'scripts'], function () {
var jsFilter = $.filter('**/*.js');
var cssFilter = $.filter('**/*.css');
var assets = $.useref.assets({searchPath: '{.tmp,src}' });
return gulp.src('src/*.html')
.pipe(assets)
.pipe(assets.restore())
.pipe($.useref())
.pipe(gulp.dest('dist'))
.pipe($.size());
});
gulp.task('images', function () {
return gulp.src('src/images/**/*')
.pipe($.imagemin({
optimizationLevel: 3,
progressive: true,
interlaced: true
}))
.pipe(gulp.dest('dist/images'))
.pipe($.size());
});
/*------------------------------------*\
JADE
\*------------------------------------*/
gulp.task('jade', function(){
return gulp.src([
'./src/jade/**/*.jade',
'!**/_*'
])
.pipe($.jade({
pretty : true
}))
.pipe(gulp.dest('./src/'))
;
});
gulp.task('fonts', function () {
return gulp.src(['src/fonts/*.{eot,svg,ttf,woff}', 'src/bower_components/fontawesome/fonts/*'])
.pipe($.flatten())
.pipe(gulp.dest('dist/fonts'))
.pipe($.size());
});
gulp.task('replacefontPath', ['html'], function(){
return gulp.src('dist/styles/*.css')
.pipe($.replace('bower_components/fontawesome/', ''))
.pipe(gulp.dest('dist/styles'));
})
gulp.task('extras', function () {
return gulp.src(['app/*.*', '!app/*.html'], { dot: true })
.pipe(gulp.dest('dist'));
});
gulp.task('copycss', function(){
return gulp.src(['.tmp/styles/ie.css', '.tmp/styles/print.css'])
.pipe(gulp.dest('dist/styles'));
})
gulp.task('build', ['html', 'images', 'fonts', 'extras', 'copycss', 'replacefontPath']);
gulp.task('clean', function () {
return gulp.src(['.tmp', 'dist'], { read: false }).pipe($.clean());
});
gulp.task('default', ['clean'], function () {
gulp.start('build');
});
gulp.task('connect', function () {
var connect = require('connect');
var app = connect()
.use(require('connect-livereload')({ port: 35729 }))
.use(connect.static('src'))
.use(connect.static('.tmp'))
.use(connect.directory('src'));
require('http').createServer(app)
.listen(9000)
.on('listening', function () {
console.log('Started connect web server on http://localhost:9000');
});
});
gulp.task('watch', ['connect'], function () {
var server = $.livereload();
// watch for changes
gulp.watch([
'src/*.html',
'.tmp/styles/*.css',
'src/scripts/**/*.js',
'src/images/**/*'
]).on('change', function (file) {
server.changed(file.path);
});
gulp.watch('src/styles/**/*.scss', ['styles']);
gulp.watch('src/scripts/**/*.js', ['scripts']);
gulp.watch('src/images/**/*', ['images']);
gulp.watch('src/jade/**/*.jade', ['jade']);
});