forked from BinaryStudioAcademy/bsa-2022-vse-bude
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
69 lines (66 loc) · 1.51 KB
/
rollup.config.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
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import dts from 'rollup-plugin-dts';
import del from 'rollup-plugin-delete';
import { terser } from 'rollup-plugin-terser';
import generatePackageJson from 'rollup-plugin-generate-package-json';
const packageJson = require('./package.json');
const outDir = 'build';
const resolvedFolders = [
'common',
'helpers',
'exceptions',
'validation-schemas',
];
const main = 'index.cjs.js';
const module = 'index.esm.js';
const types = 'index.d.ts';
export default [
{
input: packageJson.main,
output: [
{
file: `${outDir}/${main}`,
format: 'cjs',
},
{
file: `${outDir}/${module}`,
format: 'esm',
},
],
plugins: [
del({ targets: [outDir] }),
resolve(),
commonjs(),
typescript({ tsconfig: './tsconfig.json' }),
terser({
compress: {
passes: 2,
properties: false,
},
}),
generatePackageJson({
outputFolder: outDir,
baseContents: {
...packageJson,
main,
module,
types,
scripts: undefined,
},
}),
],
},
{
input: `${outDir}/${types}`,
output: [{ file: `${outDir}/${types}`, format: 'esm' }],
plugins: [
dts(),
del({
targets: resolvedFolders.map((folder) => `${outDir}/${folder}`),
hook: 'buildEnd',
}),
],
},
];