-
Notifications
You must be signed in to change notification settings - Fork 12
/
gulpfile.js
72 lines (61 loc) · 2.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
const gulp = require('gulp');
const concat = require('gulp-concat');
const del = require('del');
const terser = require('gulp-terser'); // see here for minify options: https://github.com/terser/terser#minify-options
const package = require('./package.json');
const header = require('gulp-header');
const jsdoc2md = require('jsdoc-to-markdown');
const fs = require('fs');
const path = require('path');
const paths = {
src : 'src/**/*.js',
build : 'build',
outputFile : 'BBCore.min.js',
karmaConfig : `${__dirname}/spec/karma.conf.js`,
docSource : 'docs/build',
root : './'
}
const filepathsToConcat = [
'src/bbcore.js',
'src/modules/bbcore.api.js',
'src/modules/bbcore.auth.js',
'src/modules/bbcore.contacts.js',
'src/modules/bbcore.email.js',
'src/modules/bbcore.extras.js',
'src/modules/bbcore.helpers.js',
'src/modules/bbcore.video.js',
'src/modules/bbcore.videoRecorder.js'
];
const dateObject = new Date();
const today = `${dateObject.getFullYear()}-${dateObject.getMonth() + 1}-${dateObject.getDate()}`;
const coreHeader = `/*! ${package.name} ${today} */\n`
const docTitle = 'README.md';
gulp.task('combine-js', () => {
return gulp.src(filepathsToConcat)
.pipe(concat(paths.outputFile))
.pipe(gulp.dest(paths.build));
});
gulp.task('make-docs', done => {
const output = jsdoc2md.renderSync({ files: filepathsToConcat.map(filepath => path.join(__dirname, filepath)) });
fs.writeFileSync(path.join(paths.docSource, 'BBCore.combined.md'), output);
return done();
});
gulp.task('build', gulp.series('combine-js', 'make-docs'));
gulp.task('clean', done => {
del([paths.build, paths.root + docTitle]);
done();
});
gulp.task('compress', done => {
gulp.src(`${paths.build}/${paths.outputFile}`)
.pipe(terser())
.pipe(gulp.dest(paths.build))
done();
});
gulp.task('add-core-header', () => {
return gulp.src(`${paths.build}/${paths.outputFile}`)
.pipe(header(coreHeader))
.pipe(gulp.dest(paths.build));
});
gulp.task('default', () => {
console.log('Enter a task to perform an action.');
});