-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.ts
59 lines (56 loc) · 1.32 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
import resolve from '@rollup/plugin-node-resolve';
import { createRequire } from 'node:module';
import path from 'path';
import dts from 'rollup-plugin-dts';
import esbuild from 'rollup-plugin-esbuild';
import { nodeExternals } from 'rollup-plugin-node-externals';
const rq = createRequire(import.meta.url);
const pkg = rq('./package.json');
const legacyOutputDefaults = {
esModule: true,
interop: 'compat',
};
export default [
{
input: 'src/index.ts',
plugins: [
nodeExternals({
deps: true,
include: ['react', '@emotion/css', '@grafana/data', '@grafana/ui', '@grafana/runtime', 'lodash'],
packagePath: './package.json',
}),
resolve(),
esbuild({
target: 'es2018',
tsconfig: 'tsconfig.build.json',
}),
],
output: [
{
format: 'cjs',
sourcemap: true,
dir: path.dirname(pkg.main),
...legacyOutputDefaults,
},
{
format: 'esm',
sourcemap: true,
dir: path.dirname(pkg.module),
preserveModules: true,
preserveModulesRoot: './src',
...legacyOutputDefaults,
},
],
},
{
input: './compiled/index.d.ts',
plugins: [dts()],
output: {
file: pkg.types,
format: 'es',
},
watch: {
exclude: './compiled/**',
},
},
];