-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.ts
43 lines (40 loc) · 1.2 KB
/
rollup.config.ts
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
import { readFileSync } from 'node:fs'
import typescript from '@rollup/plugin-typescript'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import { visualizer } from 'rollup-plugin-visualizer'
import { RollupOptions } from 'rollup'
import json from '@rollup/plugin-json'
const pkg = JSON.parse(
readFileSync('./package.json', {
encoding: 'utf8'
})
)
// import replace from '@rollup/plugin-replace'
// import terser from '@rollup/plugin-terser'
const isProd = process.env.NODE_ENV === 'production'
const isDev = process.env.NODE_ENV === 'development'
const dependencies = pkg.dependencies as Record<string, string> | undefined
const config: RollupOptions = {
input: { index: 'src/index.ts', cli: 'src/cli.ts' },
output: [
{
dir: 'dist',
format: 'cjs',
sourcemap: isDev,
exports: 'auto'
}
],
makeAbsoluteExternalsRelative: true,
preserveEntrySignatures: 'strict',
plugins: [
json(),
nodeResolve({
preferBuiltins: true
}),
commonjs(),
typescript({ tsconfig: './tsconfig.build.json', sourceMap: isDev })
],
external: [...(dependencies ? Object.keys(dependencies) : [])]
}
export default config