-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.ts
45 lines (44 loc) · 1.12 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
import { fileURLToPath } from 'url'
import { defineConfig } from 'rollup'
import RollupClear from 'rollup-plugin-clear'
import typescript2 from 'rollup-plugin-typescript2'
import { dts } from 'rollup-plugin-dts'
export default defineConfig([
{
input: './index.ts',
external: ['jszip'],
plugins: [
RollupClear({
targets: ['dist/es', 'dist/lib'], // 每次打包清空dist目录,从新生成
watch: false,
}),
typescript2({
exclude: 'src/**/*test.ts',
}),
],
output: [
{
format: 'es',
entryFileNames: '[name].js',
preserveModules: true,
dir: fileURLToPath(new URL('dist/es', import.meta.url)), // 配置打包根目录
indent: false,
},
{
format: 'cjs',
entryFileNames: '[name].js',
preserveModules: true,
dir: fileURLToPath(new URL('dist/lib', import.meta.url)),
indent: false,
},
],
},
{
input: './types/global.d.ts',
output: [
{ file: 'dist/es/types/global.d.ts' },
{ file: 'dist/lib/types/global.d.ts' },
],
plugins: [dts()],
},
])