forked from nanxiaobei/antd-img-crop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.ts
35 lines (27 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
import type { RollupOptions } from 'rollup';
import dts from 'rollup-plugin-dts';
import postcss from 'rollup-plugin-postcss';
import replace from '@rollup/plugin-replace';
import typescript from '@rollup/plugin-typescript';
import { readFileSync } from 'fs';
const pkg = JSON.parse(readFileSync('./package.json') as unknown as string);
const input = 'src/ImgCrop.tsx';
const cjsOutput = { file: pkg.main, format: 'cjs', exports: 'auto' } as const;
const esmOutput = { file: pkg.module, format: 'es' } as const;
const dtsOutput = { file: pkg.types, format: 'es' } as const;
const tsPlugin = typescript();
const postcssPlugin = postcss({ minimize: true });
const replacePlugin = replace({ preventAssignment: true, '/es/': '/lib/' });
const cjsPlugins = [tsPlugin, postcssPlugin, replacePlugin];
const esmPlugins = [tsPlugin, postcssPlugin];
const external = [
...Object.keys({ ...pkg.dependencies, ...pkg.peerDependencies }),
/^react($|\/)/,
/^antd($|\/)/,
];
const config: RollupOptions[] = [
{ input, output: cjsOutput, plugins: cjsPlugins, external },
{ input, output: esmOutput, plugins: esmPlugins, external },
{ input, output: dtsOutput, plugins: [dts()], external: [/\.css$/] },
];
export default config;