-
Notifications
You must be signed in to change notification settings - Fork 2
/
Gulpfile.js
121 lines (108 loc) · 3.1 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
var gulp = require('gulp');
var sass = require('gulp-sass');
var minifyCSS = require('gulp-minify-css');
var babelify = require('babelify');
var rename = require('gulp-rename');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var exec = require('child_process').exec;
var args = require('yargs').argv;
var express = require('express');
var util = require('gulp-util');
var livereload = require('gulp-livereload');
var uglify = require('gulp-uglify')
var streamify = require('gulp-streamify')
var files = {
css: 'public/*.css',
scss: 'public/*.scss',
html: 'public/*.html'
};
var watch_paths = {
js: ['./*.js', './src/*.js'],
assets: './public/*.{html,scss,css}'
};
gulp.task('pre-build', ['sass', 'copy-html', 'copy-css'], function(done) {
return exec('node bin/hook.js', done);
});
gulp.task('build', ['pre-build'], function(b) {
return browserify()
.transform(babelify)
.add('./index.js', {entry: true})
.external('ui_plugin')
.external('ui_object')
.external('base_object')
.external('browser')
.external('zepto')
.external('media_control')
.external('playback')
.external('core_plugin')
.external('ui_core_plugin')
.external('container_plugin')
.external('ui_container_plugin')
.bundle()
.pipe(source('main.js'))
.pipe(rename( 'channels.js'))
.pipe(gulp.dest('./dist'));
});
gulp.task('release', ['pre-build'], function() {
return browserify()
.transform(babelify)
.add('./index.js', {entry: true})
.external('ui_plugin')
.external('ui_object')
.external('base_object')
.external('browser')
.external('zepto')
.external('media_control')
.external('playback')
.external('core_plugin')
.external('ui_core_plugin')
.external('container_plugin')
.external('ui_container_plugin')
.external('mediator')
.bundle()
.pipe(source('main.js'))
.pipe(rename( 'channels.min.js'))
.pipe(streamify(uglify()))
.pipe(gulp.dest('./dist'));
});
gulp.task('sass', function () {
return gulp.src(files.scss)
.pipe(sass({
includePaths: ['node_modules/compass-mixins/lib']
}))
.pipe(minifyCSS())
.pipe(gulp.dest("build"));
});
gulp.task("copy-css", function() {
return gulp.src(files.css)
.pipe(minifyCSS())
.pipe(gulp.dest('build'));
});
gulp.task("copy-html", function() {
return gulp.src(files.html)
.pipe(gulp.dest('build'));
});
gulp.task('serve', ['build', 'watch'], function() {
express()
.use(express.static('.'))
.use(express.static('./dist'))
.listen(3000);
util.log(util.colors.bgGreen('Listening on port 3000'));
});
gulp.task('watch', function() {
var reloadServer = livereload();
var js = gulp.watch(watch_paths.js);
js.on('change', function(event) {
gulp.start('build', function() {
reloadServer.changed(event.path);
});
});
var assets = gulp.watch(watch_paths.assets);
assets.on('change', function(event) {
gulp.start(['build'], function() {
reloadServer.changed(event.path);
});
});
util.log(util.colors.bgGreen('Watching for changes...'));
});