forked from jackrugile/elematter-js13k
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
66 lines (57 loc) · 1.66 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
var gulp = require( 'gulp' ),
gulpLoadPlugins = require( 'gulp-load-plugins' ),
p = gulpLoadPlugins(),
src = 'src/',
temp = src + 'temp/',
dest = 'build/';
gulp.task( 'css', function() {
return gulp.src( src + 'css/main.css' )
.pipe( p.minifyCss() )
.pipe( p.rename( '_.css' ) )
.pipe( gulp.dest( temp ) );
});
gulp.task( 'jshint', function() {
return gulp.src( [ src + 'js/**/*.js', '!' + src + 'js/vendor/*.js' ] )
.pipe( p.jshint() )
.pipe( p.jshint.reporter( 'jshint-stylish' ) );
});
gulp.task( 'js', [ 'jshint' ], function() {
return gulp.src( src + 'js/imports.js' )
.pipe( p.imports() )
.pipe( p.rename( '_full.js' ) )
.pipe( gulp.dest( temp ) )
.pipe( p.uglify() )
.pipe( p.rename( '_.js' ) )
.pipe( gulp.dest( temp ) );
});
gulp.task( 'html', [ 'css', 'js' ], function() {
return gulp.src( src + 'index.php' )
.pipe( p.php2html( { getData:{ prod: 1 } } ) )
.pipe( p.htmlmin( {
removeComments: true,
collapseWhitespace: true,
conservativeCollapse: true,
removeAttributeQuotes: true
}))
.pipe( gulp.dest( dest ) );
});
gulp.task('build', [ 'html' ], function() {
return gulp.src( dest + 'index.html' )
.pipe( p.zip( 'game.zip' ) )
.pipe( p.size() )
//.pipe( p.micro( { limit: 13 * 1024 } ) )
.pipe( gulp.dest( dest ) )
.pipe( p.notify( 'Build Complete' ) );
});
gulp.task( 'clean', function() {
return gulp.src( [ dest ], { read: false } )
.pipe( p.rimraf() );
});
gulp.task('default', function() {
gulp.start( [ 'build', 'watch' ] );
});
gulp.task( 'watch', function() {
gulp.watch( src + '*.php', [ 'build' ] );
gulp.watch( src + 'css/**/*.css', [ 'build' ] );
gulp.watch( src + 'js/**/*.js', [ 'build' ] );
});