-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.mjs
More file actions
52 lines (51 loc) · 1.58 KB
/
rollup.config.mjs
File metadata and controls
52 lines (51 loc) · 1.58 KB
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
import babel from '@rollup/plugin-babel'
import commonjs from '@rollup/plugin-commonjs'
import nodeResolve from '@rollup/plugin-node-resolve'
import terser from '@rollup/plugin-terser'
import typescript from '@rollup/plugin-typescript'
import copy from 'rollup-plugin-copy'; // 导入插件
export default {
input: 'src/index.ts',
output: [
{
file: 'dist/index.esm.js', // 从 dist/esm/ 移动到 dist/
format: 'esm',
sourcemap: true
},
{
file: 'dist/index.cjs.js', // 从 dist/cjs/ 移动到 dist/
format: 'cjs',
exports: 'named',
sourcemap: true
},
{
file: 'dist/index.umd.js', // 从 dist/umd/ 移动到 dist/
format: 'umd',
name: 'td-ui',
sourcemap: true
},
{
file: 'dist/index.min.js',
format: 'umd',
name: 'td-ui',
plugins: [terser()],
sourcemap: true
}
],
plugins: [
nodeResolve(),
commonjs(),
typescript({tsconfig: './tsconfig.json'}), // 显式指定 tsconfig 路径
babel({
babelHelpers: 'bundled',
extensions: ['.ts'],
presets: [['@babel/preset-env', {targets: '> 0.25%, not dead'}]]
}),
copy({ // 新增配置
targets: [
{src: ['package.json', 'README.md'], dest: 'dist/'}, // 复制到 dist/ 目录
],
}),
],
external: id => /node_modules/.test(id) // 修正条件:仅排除 node_modules
}