-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
100 lines (87 loc) · 2.43 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
var gulp = require('gulp')
, gutil = require('gulp-util')
, del = require('del')
, concat = require('gulp-concat')
, rename = require('gulp-rename')
, minifycss = require('gulp-minify-css')
, minifyhtml = require('gulp-minify-html')
, processhtml = require('gulp-processhtml')
, jshint = require('gulp-jshint')
, uglify = require('gulp-uglify')
, connect = require('gulp-connect')
, paths;
paths = {
assets: 'src/assets/**/*',
css: 'src/css/*.css',
libs: [
'src/bower_components/phaser-official/build/phaser.min.js'
],
js: ['src/js/**/*.js'],
dist: './dist/'
};
gulp.task('clean', function (cb) {
del([paths.dist], cb);
});
gulp.task('copy-assets', ['clean'], function () {
gulp.src(paths.assets)
.pipe(gulp.dest(paths.dist + 'assets'))
.on('error', gutil.log);
});
gulp.task('copy-vendor', ['clean'], function () {
gulp.src(paths.libs)
.pipe(gulp.dest(paths.dist))
.on('error', gutil.log);
});
gulp.task('uglify', ['clean','lint'], function () {
gulp.src(paths.js)
.pipe(concat('main.min.js'))
.pipe(gulp.dest(paths.dist))
.pipe(uglify({outSourceMaps: false}))
.pipe(gulp.dest(paths.dist));
});
gulp.task('minifycss', ['clean'], function () {
gulp.src(paths.css)
.pipe(minifycss({
keepSpecialComments: false,
removeEmpty: true
}))
.pipe(rename({suffix: '.min'}))
.pipe(gulp.dest(paths.dist))
.on('error', gutil.log);
});
gulp.task('processhtml', ['clean'], function() {
gulp.src('src/index.html')
.pipe(processhtml({}))
.pipe(gulp.dest(paths.dist))
.on('error', gutil.log);
});
gulp.task('minifyhtml', ['clean'], function() {
gulp.src('dist/index.html')
.pipe(minifyhtml())
.pipe(gulp.dest(paths.dist))
.on('error', gutil.log);
});
gulp.task('lint', function() {
gulp.src(paths.js)
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('default'))
.on('error', gutil.log);
});
gulp.task('html', function(){
gulp.src('src/*.html')
.pipe(connect.reload())
.on('error', gutil.log);
});
gulp.task('connect', function () {
connect.server({
root: [__dirname + '/src'],
port: 9000,
livereload: true
});
});
gulp.task('watch', function () {
gulp.watch(paths.js, ['lint']);
gulp.watch(['./src/index.html', paths.css, paths.js], ['html']);
});
gulp.task('default', ['connect', 'watch']);
gulp.task('build', ['copy-assets', 'copy-vendor', 'uglify', 'minifycss', 'processhtml', 'minifyhtml']);