-
Notifications
You must be signed in to change notification settings - Fork 52
/
gulpfile.js
85 lines (75 loc) · 1.83 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
var gulp = require('gulp');
var del = require('del');
var connect = require('gulp-connect');
var sourcemaps = require('gulp-sourcemaps');
var to5 = require('gulp-6to5');
var runSequence = require('run-sequence');
var stylus = require('gulp-stylus');
var rename = require('gulp-rename');
var path = require('path');
var JS = ['src/**/*.js'];
var port = 8005;
var reloadPort = 35729;
// Clean Output Directory
gulp.task('clean', function(callback) {
del(['.tmp', 'dist'], function(err, deletedFiles) {
callback();
});
});
gulp.task('js', function() {
gulp.src(JS)
.pipe(sourcemaps.init())
.pipe(to5({
blacklist: ['useStrict', 'regenerator'],
modules: 'amd'
}))
//.pipe(concat('all.js'))
.pipe(rename({ extname: '.js' }))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dist/'));
});
gulp.task('style', function() {
return gulp.src(['src/stylus/*.styl', 'src/css/**/*.css'])
.pipe(sourcemaps.init())
.pipe(stylus({
//linenos: true
}))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dist/css/'));
});
gulp.task('build-lib', function() {
var libs = {
'jquery': 'dist/*',
'requirejs': 'require.js',
'sprintf': 'dist/sprintf.*',
'q': 'q.js',
'co': 'co.js'
};
for (var name in libs) {
var src = path.join('bower_components', name, libs[name]);
var dest = path.join('dist/lib', name);
gulp.src(src).pipe(gulp.dest(dest));
}
})
gulp.task('build', function(callback) {
runSequence(
['build-lib'],
['js', 'style'],
callback
);
});
gulp.task('serve', function() {
connect.server({
host: '0.0.0.0',
port: port
});
});
gulp.task('dev', ['build', 'serve'], function() {
gulp.watch(['src/js/**'], { interval: 500, debounceDelay: 1000 }, ['js']);
})
gulp.task('default', function() {
runSequence(
['clean'],
['build']
);
});