-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
114 lines (98 loc) · 2.84 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
var gulp = require('gulp'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
jshint = require('gulp-jshint'),
filter = require('gulp-filter'),
jade = require('gulp-jade'),
imgmin = require('gulp-imagemin'),
bower = require('main-bower-files'),
stylus = require('gulp-stylus'),
connect = require('gulp-connect'),
nib = require('nib'),
fallback = require('connect-history-api-fallback');
var paths = {
destjs: 'app/dist/src',
destcss: 'app/dist/css',
destaudio: 'app/dist/audio',
destimages: 'app/dist/images',
dest: 'app/dist',
js: 'app/src/**/*.js',
styl: 'app/styles/*.styl',
audio: 'app/audio/*.mp3',
images: 'app/images/*.+(png|gif)',
jade: 'app/*.jade'
}
gulp.task('scripts', function(){
return gulp.src(paths.js)
.pipe(jshint())
.pipe(concat('build.js'))
.pipe(uglify())
.pipe(gulp.dest(paths.destjs))
.pipe(connect.reload());
});
gulp.task('arnoldc', function(){
return gulp.src("app/src/arnoldc/*.arnoldc")
.pipe(gulp.dest("app/dist/src/arnoldc"));
});
gulp.task('styles', function(){
return gulp.src(paths.styl)
.pipe(concat('styles.styl'))
.pipe(stylus({
use: nib(),
compress: true
}))
.pipe(gulp.dest(paths.destcss))
.pipe(connect.reload());
});
gulp.task('views', function(){
return gulp.src(paths.jade)
.pipe(jade())
.pipe(gulp.dest(paths.dest))
.pipe(connect.reload());
});
gulp.task('images', function(){
return gulp.src(paths.images)
.pipe(imgmin({
optimizationLeval: 3,
progressive: true
}))
.pipe(gulp.dest(paths.destimages));
});
gulp.task('audios', function(){
return gulp.src(paths.audio)
.pipe(gulp.dest(paths.destaudio));
});
gulp.task('bower', function(){
var jsFilter = filter('**/*.js');
var cssFilter = filter('**/*.css');
var fontFilter = filter('**/*.+(svg|ttf|woff)');
return gulp.src(bower(),{
base: 'bower_components'
})
.pipe(jsFilter)
.pipe(concat('bower.all.js'))
.pipe(uglify())
.pipe(gulp.dest(paths.destjs))
.pipe(jsFilter.restore())
.pipe(cssFilter)
.pipe(concat('bower.all.css'))
.pipe(gulp.dest(paths.destcss))
.pipe(cssFilter.restore())
.pipe(fontFilter)
.pipe(gulp.dest(paths.dest+"/fonts/"));
});
gulp.task('server', ['default', 'watch'],function(){
connect.server({
port: 9090,
root: 'app/dist',
livereload: true,
middleware: function(){
return [fallback];
}
});
});
gulp.task('watch', function() {
gulp.watch([paths.styl, paths.js, paths.jade, paths.images], ['styles', 'views', 'scripts' ]);
});
gulp.task('default', ['scripts', 'styles', 'views', 'images']);
gulp.task('build', ['bower','audios','arnoldc','default']);