forked from danbovey/EmojiPanel
-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
66 lines (54 loc) · 1.72 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
const gulp = require('gulp');
const util = require('gulp-util');
const sass = require('gulp-sass');
const source = require('vinyl-source-stream');
const buffer = require('vinyl-buffer');
const browserify = require('browserify');
const watchify = require('watchify');
const babel = require('babelify');
const uglify = require('gulp-uglify');
const runSequence = require('run-sequence');
const rename = require('gulp-rename');
let dev = false;
gulp.task('js', () => {
const bundler = watchify(browserify('./src/index.js', { debug: dev })
.transform(babel, {
presets: ['es2015']
}));
const rebundle = () => {
console.log('-> bundling...');
return bundler.bundle()
.once('error', function(err) { console.error(err); this.emit('end'); })
.pipe(source('emojipanel.js'))
.pipe(buffer())
.pipe(!dev ? uglify() : util.noop())
.pipe(gulp.dest('./dist'))
.pipe(gulp.dest('./docs/js'))
.once('end', () => {
console.log('-> bundled!')
if(!dev) {
process.exit();
}
});
};
if(dev) {
bundler.on('update', () => rebundle());
}
return rebundle();
});
gulp.task('scss', () => {
return gulp.src('./scss/panel.scss')
.pipe(sass({ outputStyle: 'compressed' }).on('error', sass.logError))
.pipe(rename('emojipanel.css'))
.pipe(gulp.dest('./dist'))
.pipe(gulp.dest('./docs/css'));
});
gulp.task('build', () => {
runSequence('scss', 'js');
});
gulp.task('watch', () => {
dev = true;
runSequence('scss', 'js');
gulp.watch('scss/**/*.scss', ['scss']);
});
gulp.task('default', ['watch']);