-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
103 lines (65 loc) · 2.89 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
// configure gulp tasks
// global task variables
var gulp = require( 'gulp' );
var sass = require( 'gulp-sass' );
var notify = require( 'gulp-notify' );
var rename = require( 'gulp-rename' );
var concat = require( 'gulp-concat' );
var path = require( 'path' );
var dateformat = require( 'dateformat' );
var sourcemaps = require( 'gulp-sourcemaps' );
var uglify = require( 'gulp-uglify' );
// other variables
var basedate = new Date();
var timestamp = dateformat( basedate, 'yyyy.mm.dd hh.MM' );
notifycon = function( task ) {
return './assets/img/notifycon_' + task + '.png';
};
gulp.Gulp.prototype.__runTask = gulp.Gulp.prototype._runTask;
gulp.Gulp.prototype._runTask = function( task ) {
this.currentTask = task;
this.__runTask(task);
}
// javascript task variables
var jspath = './inc/js/build/**/*.js';
// tasks
// stylesheet
gulp.task( 'stylesheets', function() {
gulp.src( 'assets/scss/codepixel.devtools.scss' )
.pipe( sass().on( 'error', sass.logError ) )
.pipe( gulp.dest( './assets/css/' ) )
.pipe( notify({
title: 'compiled',
message: '<%= file.relative %> : <%= options.timestamp %>',
onLast: true,
icon: path.join( __dirname, notifycon( this.currentTask.name ) ),
templateOptions: {
timestamp: timestamp
}
}) );
});
// javascript
gulp.task( 'javascript', function() {
return gulp.src( jspath )
.pipe( sourcemaps.init() )
.pipe( concat( 'state.gameday.js' ) )
.pipe( gulp.dest( './inc/js/build/' ) )
.pipe( rename( 'state.gameday.min.js' ) )
.pipe( uglify() )
.pipe( sourcemaps.write( './' ) )
.pipe( gulp.dest( '.inc/js/build/' ) )
.pipe( notify({
title: 'compiled',
message: '<%= file.relative %> : <%= options.timestamp %>',
onLast: true,
icon: path.join( __dirname, notifycon( this.currentTask.name ) ),
templateOptions: {
timestamp: timestamp
}
}) );
});
// watch
gulp.task( 'watch', function() {
gulp.watch( 'assets/scss/**/*.scss', [ 'stylesheets' ] );
});
gulp.task( 'default', [ 'stylesheets', 'javascript', 'watch' ] );