-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.mjs
57 lines (54 loc) · 1.44 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
import path from 'path';
import { babel } from '@rollup/plugin-babel';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
const packageName = process.env.PACKAGE_NAME;
const input = process.env.INPUT || path.resolve(__dirname, 'src', 'index.js');
const outputDirectory = process.env.OUTPUT_DIRECTORY || path.resolve(__dirname, 'dist');
const cjsOutputDirectory = path.resolve(outputDirectory, 'cjs');
const esmOutputDirectory = path.resolve(outputDirectory, 'esm');
const isExternal = id => !id.startsWith('.') && !id.startsWith('/');
export default [
{
input,
output: {
file: path.join(cjsOutputDirectory, `${packageName}.js`),
format: 'cjs',
// https://rollupjs.org/guide/en/#changed-defaults
// https://rollupjs.org/guide/en/#outputinterop
interop: 'auto',
},
external: isExternal,
plugins: [
nodeResolve(),
babel({ babelHelpers: 'bundled' }),
terser({
compress: false,
mangle: false,
output: {
comments: false,
},
}),
],
},
{
input,
output: {
dir: esmOutputDirectory,
format: 'esm',
preserveModules: true,
},
external: isExternal,
plugins: [
nodeResolve(),
babel({ babelHelpers: 'bundled' }),
terser({
compress: false,
mangle: false,
output: {
comments: false,
},
}),
],
}
];