-
Notifications
You must be signed in to change notification settings - Fork 36
/
rollup.config.ts
49 lines (45 loc) · 1.16 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
44
45
46
47
48
49
import { RollupOptions } from 'rollup';
import typescript from '@rollup/plugin-typescript';
import terser from '@rollup/plugin-terser';
import replace from '@rollup/plugin-replace';
import tsConfigPaths from 'rollup-plugin-tsconfig-paths';
import { dts } from 'rollup-plugin-dts';
import { createRequire } from 'module';
const pkg = createRequire(import.meta.url)('./package.json');
const isProduction = process.env.BUILD === 'production';
const sourceFile = 'src/imgur.ts';
const jsConfig: RollupOptions = {
input: sourceFile,
output: [
{
file: pkg.main,
format: 'umd',
name: 'Imgur',
plugins: isProduction ? [terser()] : []
},
{
file: pkg.module,
format: 'es'
}
],
plugins: [
typescript(),
tsConfigPaths(),
replace({
preventAssignment: true,
__version__: pkg.version
})
]
};
const dtsConfig: RollupOptions = {
input: sourceFile,
output: {
file: pkg.types,
format: 'es'
},
plugins: [
tsConfigPaths(),
dts()
]
};
export default [jsConfig, dtsConfig];