-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
37 lines (31 loc) · 981 Bytes
/
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
const path = require('path');
const terser = require('@rollup/plugin-terser');
const del = require('del');
const gulp = require('gulp');
const rollup = require('rollup');
const typescript = require('rollup-plugin-typescript2');
const resolvePath = (name) => {
return path.resolve(__dirname, name);
};
const onwarn = (warning) => {
if (warning.code === 'CIRCULAR_DEPENDENCY') return;
console.warn(`(!) ${warning.message}`);
};
const dirBuild = resolvePath('lib');
gulp.task('clean', () => {
return del([dirBuild], { force: true });
});
const externalDeps = ['react', 'react-dom', 'axios'];
gulp.task('build', async () => {
const bundle = await rollup.rollup({
input: resolvePath('./src/index.ts'),
external: externalDeps,
plugins: [typescript(), terser()],
onwarn,
});
await bundle.write({
file: `${dirBuild}/index.js`,
format: 'esm',
});
});
gulp.task('default', gulp.series('clean', 'build'));