forked from mkosir/react-parallax-tilt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.ts
78 lines (73 loc) · 2.08 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import commonjs from '@rollup/plugin-commonjs';
import typescript from '@rollup/plugin-typescript';
import { defineConfig } from 'rollup';
import dts from 'rollup-plugin-dts';
// @ts-expect-error types package is broken - https://www.npmjs.com/package/@types/rollup-plugin-size-snapshot
import { sizeSnapshot } from 'rollup-plugin-size-snapshot';
import { terser } from 'rollup-plugin-terser';
import visualizer from 'rollup-plugin-visualizer';
import packageJson from './package.json';
import tsConfig from './tsconfig.base.json';
const isProduction = process.env.NODE_ENV === 'production';
const inputFile = 'src/index.ts';
const rollupConfig = defineConfig([
{
input: inputFile,
output: [
{
file: packageJson.main,
name: packageJson.name,
format: 'umd',
sourcemap: !isProduction,
globals: {
react: 'React',
'react-dom': 'ReactDOM',
},
},
{
file: packageJson.module,
format: 'esm',
sourcemap: !isProduction,
},
],
plugins: [
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
sizeSnapshot({ matchSnapshot: Boolean(process.env.MATCH_SNAPSHOT) }),
commonjs(),
typescript({
tsconfig: './tsconfig.prod.json',
}),
terser({
output: { comments: false },
compress: {
pure_getters: true,
},
toplevel: true,
}),
visualizer({
filename: 'bundle-analysis.html',
title: `${packageJson.name} - Rollup Visualizer`,
open: false,
}),
],
// Ensure dependencies are not bundled with the library
external: [
...Object.keys(packageJson.peerDependencies),
// ...Object.keys(packageJson.dependencies ?? {}),
],
},
{
input: inputFile,
output: { file: packageJson.types, format: 'esm' },
plugins: [
dts({
compilerOptions: {
baseUrl: tsConfig.compilerOptions.baseUrl,
paths: tsConfig.compilerOptions.paths,
},
}),
],
},
]);
// eslint-disable-next-line
export default rollupConfig;