-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
96 lines (81 loc) · 2.53 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
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var header = require('gulp-header');
var jshint = require('gulp-jshint');
var plumber = require('gulp-plumber');
var bump = require('gulp-bump');
var package = require('./package.json');
var banner = '/*! <%= name %> - v<%= version %> */'
function bufferedBrowserify(standaloneName) {
var transform = require('vinyl-transform');
var browserify = require('browserify');
var to5browserify = require('6to5-browserify');
return transform(function(filename) {
return browserify(filename, {standalone: standaloneName, debug: true})
.transform(to5browserify)
.bundle();
});
}
gulp.task('jshint', function() {
return gulp.src(['./index.js', './src/**/*.js'])
.pipe(jshint('./.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'));
});
gulp.task('bump', function(){
return gulp.src('./package.json')
.pipe(bump({type:'patch'}))
.pipe(gulp.dest('./'));
});
gulp.task('build', function() {
gulp.start('build-core', 'build-runtime');
});
gulp.task('release', function() {
gulp.start('jshint', 'build', 'bump');
});
gulp.task('pretest', function() {
gulp.start('build-core', 'build-test');
});
gulp.task('watch', function() {
gulp.watch('./src/**/*.js', function() {
gulp.start('jshint', 'build-core');
});
});
gulp.task('build-core', function() {
var name = 'Claylump';
return gulp.src('./src/_index.js')
.pipe(plumber())
.pipe(bufferedBrowserify(name))
.pipe(header(banner, {name: name, version: package.version}))
.pipe(rename('claylump.js'))
.pipe(gulp.dest('./dist'))
.pipe(uglify({
preserveComments: 'some'
}))
.pipe(rename('claylump.min.js'))
.pipe(gulp.dest('./dist'))
});
gulp.task('build-runtime', function() {
var name = 'ClayRuntime';
return gulp.src('./src/_runtime.js')
.pipe(bufferedBrowserify(name))
.pipe(header(banner, {name: name, version: package.version}))
.pipe(rename('claylump.runtime.js'))
.pipe(gulp.dest('./dist'))
.pipe(uglify({
preserveComments: 'some'
}))
.pipe(rename('claylump.runtime.min.js'))
.pipe(gulp.dest('./dist'))
});
gulp.task('build-test', function() {
var espower = require('gulp-espower');
gulp.src('./test/runner.js')
.pipe(bufferedBrowserify(null))
.pipe(gulp.dest('./temp'));
return gulp.src(['./test/**/*.js', '!./test/runner.js'])
.pipe(bufferedBrowserify(null))
.pipe(espower())
.pipe(gulp.dest('./temp'));
});