-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.mjs
82 lines (74 loc) · 1.77 KB
/
rollup.config.mjs
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
75
76
77
78
79
80
81
82
/* eslint-disable camelcase */
import resolve from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';
import terser from '@rollup/plugin-terser';
import summary from 'rollup-plugin-summary';
import progress from 'rollup-plugin-progress';
import externals from 'rollup-plugin-node-externals';
import { rimrafSync } from 'rimraf';
rimrafSync('dist');
const inputFiles = ['./src/index.ts'];
/** @type {import('rollup').RollupOptions} */
const prodConfig_CJS = {
input: inputFiles,
output: {
format: 'cjs',
sourcemap: false,
dir: 'dist/cjs',
preserveModules: true,
preserveModulesRoot: 'src',
exports: 'named',
},
external: [/node_modules/],
plugins: [
progress({
clearLine: false, // default: true
}),
externals({
deps: true,
devDeps: true,
}),
resolve(),
typescript({
tsconfig: 'tsconfig-cjs.build.json',
}),
terser(),
summary({
showBrotliSize: true,
showGzippedSize: true,
showMinifiedSize: true,
}),
],
};
/** @type {import('rollup').RollupOptions} */
const prodConfig_ESM = {
input: inputFiles,
output: {
format: 'esm',
sourcemap: false,
dir: 'dist/esm',
preserveModules: true,
entryFileNames: '[name].js',
},
external: [/node_modules/],
plugins: [
progress({
clearLine: false, // default: true
}),
externals({
deps: true,
devDeps: true,
}),
resolve(),
typescript({
tsconfig: 'tsconfig-esm.build.json',
}),
terser(),
summary({
showBrotliSize: true,
showGzippedSize: true,
showMinifiedSize: true,
}),
],
};
export default [prodConfig_CJS, prodConfig_ESM];