This repository has been archived by the owner on May 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
74 lines (65 loc) · 1.48 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
73
74
const fs = require('fs');
const gulp = require('gulp');
const through = require('through2');
const swig = require('swig-templates');
const rollup = require('rollup');
const babel = require('rollup-plugin-babel');
const buble = require('rollup-plugin-buble');
const { terser } = require('rollup-plugin-terser');
const { dependencies } = require('./package.json');
gulp.task('rollup', async () => {
const bundle = await rollup.rollup({
input: 'src/index.js',
plugins: [
babel({
runtimeHelpers: true,
}),
],
external(name) {
// no need to bundle dependencies
return [
'fs',
'path',
].includes(name)
|| name in dependencies
|| name.startsWith('@babel/runtime');
},
});
await Promise.all([
bundle.write({
file: 'dist/index.js',
format: 'cjs',
}),
bundle.write({
file: 'dist/index.esm.js',
format: 'es',
}),
]);
});
gulp.task('rollup-LeanCounter', async () => {
const bundle = await rollup.rollup({
input: 'src/static/LeanCounter.js',
plugins: [
buble(),
terser(),
],
});
await bundle.write({
file: 'dist/static/LeanCounter.js',
format: 'iife',
name: 'LeanCounter',
});
});
gulp.task('copy-templates', () => {
return gulp.src('src/template/*.swig')
.pipe(gulp.dest('dist/template/'));
});
gulp.task('build',
gulp.parallel(
'rollup',
gulp.series(
'rollup-LeanCounter',
'copy-templates',
),
),
);