-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.mjs
54 lines (50 loc) · 1.45 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
import commonjs from '@rollup/plugin-commonjs';
import {nodeResolve} from '@rollup/plugin-node-resolve';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import {terser} from 'rollup-plugin-terser';
import babel from '@rollup/plugin-babel';
import typescript from 'rollup-plugin-typescript2';
import json from '@rollup/plugin-json';
const extensions = ['.ts', '.tsx'];
const external = [/@babel\/runtime/, 'chalk'];
const options = [
{
input: 'src/cli.ts',
output: {
dir: 'dist/script',
format: 'cjs',
},
tsconfigOptions: {
include: ['src/cli.ts'],
},
},
{
input: 'src/index.ts',
output: {
dir: 'dist/lib',
format: 'esm',
preserveModules: true,
},
tsconfigOptions: {exclude: ['src/mode/*']},
},
];
/** @returns {import('rollup').RollupOptions} */
const makeConfig = (opt) => {
return {
input: opt.input,
output: opt.output,
external,
// 순서중요
plugins: [
json(),
nodeResolve({extensions, preferBuiltins: true}),
commonjs(),
peerDepsExternal(),
typescript({clean: true, ...opt.tsconfigOptions}),
// When using @rollup/plugin-babel with @rollup/plugin-commonjs in the same Rollup configuration, it's important to note that @rollup/plugin-commonjs must be placed before this plugin
babel({babelHelpers: 'runtime', extensions}),
terser(),
],
};
};
export default options.map((option) => makeConfig(option));