-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
56 lines (47 loc) · 1.33 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
/* eslint-disable no-undef */
const { series, src, dest } = require('gulp');
const rename = require('gulp-rename');
const uglify = require('gulp-uglify');
const source = require('vinyl-source-stream');
const rollupStream = require('@rollup/stream');
const jsdoc2md = require('jsdoc-to-markdown');
const distFolder = './dist';
const srcFolder = './src';
const docsFolder = './docs';
const fileName = 'infiniteScrollManager';
/**
* @type {import('rollup').RollupOptions}
*/
const rollupConfig = {
input: `${srcFolder}/${fileName}.js`,
output: {
format: 'esm',
file: `${fileName}.js`,
},
}
function clean() {
return import('del')
.then(del => del.deleteSync([`${distFolder}/**`]));
}
function build() {
return rollupStream(rollupConfig)
.pipe(source(`${fileName}.js`))
.pipe(dest(distFolder));
}
function minify() {
return src(`${distFolder}/*.js`)
.pipe(uglify())
.pipe(rename({ extname: '.min.js' }))
.pipe(dest(distFolder));
}
function generateDocs() {
const md = jsdoc2md.renderSync({
files: `${distFolder}/*.js`,
})
const stream = source(`${fileName}.md`);
stream.end(md);
return stream.pipe(dest(docsFolder));
}
exports.clean = clean;
exports.generateDocs = generateDocs;
exports.default = series(clean, build, minify, generateDocs);