-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathrslib.config.ts
79 lines (75 loc) · 1.55 KB
/
rslib.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import { defineConfig } from '@rslib/core';
import pkg from './package.json';
const bannerContent = `/*!
* ${pkg.name} v${pkg.version}
* (c) 2023-present Joe Shu
* @license MIT
*/`;
/**
* 设置产物兼容性
* 即使项目下有`.browserslistrc` 文件,也不会生效,可能是因为 `lib.syntax` 的默认值为 esnext 的缘故。使用 overrideBrowserslist 来解决。
* ```js
* const syntax = 'es2020'; // lib.syntax
* https://github.com/web-infra-dev/rslib/blob/8d65f3728d60254bcf1a8e24d72902ad79dae959/packages/core/src/utils/syntax.ts#L42-L153
*/
export default defineConfig({
lib: [
{
format: 'esm',
banner: {
js: bannerContent,
},
dts: true,
},
{
format: 'cjs',
banner: {
js: bannerContent,
},
},
{
format: 'umd',
banner: {
js: bannerContent,
},
umdName: 'VersionPolling',
autoExtension: false,
output: {
minify: true,
filename: {
js: `${pkg.name}.min.js`,
},
},
},
{
format: 'umd',
banner: {
js: bannerContent,
},
umdName: 'VersionPolling',
autoExtension: false,
output: {
filename: {
js: `${pkg.name}.js`,
},
},
},
],
source: {
entry: {
index: './src/index.ts',
},
},
output: {
target: 'web',
distPath: {
root: './dist',
},
overrideBrowserslist: [
'chrome >= 87',
'edge >= 88',
'firefox >= 78',
'safari >= 14',
],
},
});