This repository has been archived by the owner on Feb 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 47
/
build_app.js
52 lines (46 loc) · 1.46 KB
/
build_app.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
const gulp = require('gulp');
const sass = require('gulp-sass');
const watch = require('gulp-watch');
const batch = require('gulp-batch');
const plumber = require('gulp-plumber');
const jetpack = require('fs-jetpack');
const bundle = require('./bundle');
const utils = require('./utils');
const projectDir = jetpack;
const srcDir = jetpack.cwd('./src');
const destDir = jetpack.cwd('./app');
gulp.task('bundle', () => {
return Promise.all([
bundle(srcDir.path('background.js'), destDir.path('background.js')),
bundle(srcDir.path('sidebar.js'), destDir.path('sidebar.js')),
bundle(srcDir.path('tray.js'), destDir.path('tray.js')),
bundle(srcDir.path('menu.js'), destDir.path('menu.js')),
bundle(srcDir.path('config.js'), destDir.path('config.js')),
bundle(srcDir.path('browser.js'), destDir.path('browser.js')),
]);
});
gulp.task('sass', () => {
return gulp.src(srcDir.path('stylesheets/main.scss'))
.pipe(plumber())
.pipe(sass({
includePaths: ['node_modules']
}))
.pipe(gulp.dest(destDir.path('stylesheets')));
});
gulp.task('watch', () => {
const beepOnError = (done) => {
return (err) => {
if (err) {
utils.beepSound();
}
done(err);
};
};
watch('src/**/*.js', batch((events, done) => {
gulp.start('bundle', beepOnError(done));
}));
watch('src/**/*.scss', batch((events, done) => {
gulp.start('sass', beepOnError(done));
}));
});
gulp.task('build', ['bundle', 'sass']);