forked from snabbdom/snabbdom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
82 lines (67 loc) · 2.19 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
var gulp = require('gulp')
var clean = require('gulp-clean')
var uglify = require('gulp-uglify')
var rename = require('gulp-rename')
var sourcemaps = require('gulp-sourcemaps')
var browserify = require('browserify')
var fs = require('fs')
function standalone(name, entry, exportName) {
return browserify(entry, { debug: true, standalone: exportName || name })
.bundle()
.pipe(fs.createWriteStream('./dist/'+ name.replace(/_/g, '-') +'.js'))
}
gulp.task('bundle:snabbdom', function() {
return standalone('snabbdom_patch', './snabbdom.bundle.js', 'snabbdom')
})
gulp.task('bundle:snabbdom:init', function() {
return standalone('snabbdom', './snabbdom.js')
})
gulp.task('bundle:snabbdom:h', function() {
return standalone('h', './h.js')
})
gulp.task('bundle:snabbdom:tovnode', function() {
return standalone('tovnode', './tovnode.js')
})
gulp.task('bundle:module:class', function() {
return standalone('snabbdom_class', './modules/class.js')
})
gulp.task('bundle:module:dataset', function() {
return standalone('snabbdom_dataset', './modules/dataset.js')
})
gulp.task('bundle:module:props', function() {
return standalone('snabbdom_props', './modules/props.js')
})
gulp.task('bundle:module:attributes', function() {
return standalone('snabbdom_attributes', './modules/attributes.js')
})
gulp.task('bundle:module:style', function() {
return standalone('snabbdom_style', './modules/style.js')
})
gulp.task('bundle:module:eventlisteners', function() {
return standalone('snabbdom_eventlisteners', './modules/eventlisteners.js')
})
gulp.task('bundle', [
'bundle:snabbdom',
'bundle:snabbdom:init',
'bundle:snabbdom:h',
'bundle:snabbdom:tovnode',
'bundle:module:attributes',
'bundle:module:class',
'bundle:module:dataset',
'bundle:module:props',
'bundle:module:style',
'bundle:module:eventlisteners'
])
gulp.task('compress', ['bundle'], function() {
return gulp.src(['dist/*.js', '!dist/*.min.js'])
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(rename({ suffix: '.min' }))
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('dist'))
})
gulp.task('clean', function() {
return gulp.src('dist/*.*', {read: false})
.pipe(clean())
})
gulp.task('default', ['bundle'])