-
Notifications
You must be signed in to change notification settings - Fork 38
/
gulpfile.js
71 lines (58 loc) · 1.79 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
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 rename = require('gulp-rename');
let dev = false;
gulp.task('js', (done) => {
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());
}
rebundle();
done();
});
gulp.task('scss', (done) => {
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'));
done();
});
gulp.task('build', gulp.series('scss', 'js'));
gulp.task('dev', (done) => {
dev = true;
done();
})
gulp.task('watch', gulp.series('dev', 'scss', 'js', (done) => {
gulp.watch('scss/**/*.scss', gulp.series('scss'));
done();
}));
gulp.task('default', gulp.series('watch', (done) => {
done();
}));