-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgulpfile.js
80 lines (58 loc) · 2.56 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
var gulp = require('gulp'),
gutil = require('gulp-util'),
es = require('event-stream');
var plugins = require('gulp-load-plugins')({
camelize: true
});
var config = require('./gulpfile.config');
var isProduction = (gutil.env.prod === true ? true : false);
var date = new Date();
var nicedate = date.toISOString().replace(/(\-|:|\.)/g, '');
gulp.task('clean', function() {
return gulp.src(config.basePaths.dest)
.pipe(plugins.clean());
});
gulp.task('scripts', function() {
return es.merge(
es.merge(
gulp.src(config.typeMap.coffee, { cwd: config.typePaths.scripts.src })
.pipe(plugins.coffee()),
gulp.src(config.typeMap.js, { cwd: config.typePaths.scripts.src }))
// .pipe(plugins.jshint())
// .pipe(plugins.jshint.reporter('default'))
.pipe(isProduction ? plugins.uglify() : gutil.noop()),
gulp.src(config.typeMap.jslibs, { cwd: config.typePaths.scripts.src }))
.pipe(plugins.order(config.scriptOrder))
.pipe(plugins.concat(config.appName + '.js'))
.pipe(plugins.size({ title: 'scripts', showFiles: false, gzip: true }))
.pipe(isProduction ? gutil.noop() : plugins.connect.reload())
.pipe(gulp.dest(config.typePaths.scripts.dest));
});
gulp.task('extras', function() {
return gulp.src(config.appFiles.extras, { cwd: config.typePaths.extras.src })
.pipe(plugins.size({ title: 'extras', showFiles: false }))
.pipe(isProduction ? gutil.noop() : plugins.connect.reload())
.pipe(gulp.dest(config.typePaths.extras.dest));
});
gulp.task('bundle', function() {
var archiveName = config.appName + '.' + nicedate + '.zip';
console.log(archiveName);
return gulp.src(config.basePaths.dest + config.GLOBSTAR)
.pipe(plugins.zip(archiveName))
.pipe(plugins.size({ title: 'Bundle', showFiles: true }))
.pipe(gulp.dest('..'));
});
gulp.task('rename', function() {
return gulp.src(config.typePaths.templates.dest + 'index.html')
.pipe(isProduction ? plugins.rename('index.' + nicedate + '.html') : gutil.noop())
.pipe(isProduction ? plugins.rename(config.appName + '.' + nicedate + '.html') : gutil.noop())
.pipe(gulp.dest(config.typePaths.templates.dest));
});
// Define the default task as a sequence of the above tasks
// Additionally, enable production build on any task by adding "--prod"
gulp.task('build', ['clean'], function() {
gulp.start('extras', 'scripts', 'rename');
});
gulp.task('default', function() {
gulp.start('build');
});