-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
rollup.config.mjs
35 lines (32 loc) · 947 Bytes
/
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
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import nodeResolve from '@rollup/plugin-node-resolve'
import typescript from '@rollup/plugin-typescript'
import { terser } from 'rollup-plugin-terser'
import packageJson from './package.json' assert { type: 'json' }
const { main, module: moduleFile, dependencies = {} } = packageJson
const plugins = [
json({ preferConst: true }),
nodeResolve(),
commonjs(),
typescript({ resolveJsonModule: false }),
!process.env.ROLLUP_WATCH && terser(),
]
export default [
{
plugins,
external: Object.keys(dependencies),
input: `src/entry.ts`,
output: { file: main, format: 'cjs', exports: 'named' },
},
{
plugins,
input: `src/entry.ts`,
output: { file: moduleFile, format: 'esm' },
},
{
plugins,
input: `src/polyfill.browser.ts`,
output: { file: main.replace(/\.[^.]+$/, '.browser.js'), format: 'iife' },
},
]