-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.ts
38 lines (35 loc) · 1.09 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
import alias from '@rollup/plugin-alias';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import { readFileSync } from 'fs';
import path from 'path';
import { defineConfig } from 'rollup';
import dts from 'rollup-plugin-dts';
import esbuild from 'rollup-plugin-esbuild';
import { fileURLToPath } from 'url';
const pkg = JSON.parse(readFileSync('./package.json').toString('utf-8'));
const __dirname = fileURLToPath(new URL('.', import.meta.url));
const plugins = [
alias({
entries: [{ find: '@', replacement: path.resolve(__dirname, 'src') }],
}),
nodeResolve({ extensions: ['.ts'] }),
esbuild({ include: /\.[jt]sx?$/ }),
];
export default defineConfig([
{
input: `src/index.ts`,
plugins,
output: [
{ file: pkg.module, format: 'es', sourcemap: true },
{ file: pkg.main, format: 'cjs', sourcemap: true },
{ file: pkg.browser, format: 'umd', sourcemap: true, name: 'lexorank' },
],
external: [],
},
{
input: `src/index.ts`,
plugins: [plugins[0], plugins[1], dts()],
output: [{ file: pkg.types, format: 'es' }],
external: [],
},
]);