-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.ts-back
118 lines (115 loc) · 3.47 KB
/
rollup.config.ts-back
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import alias from '@rollup/plugin-alias';
import { babel } from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import path from 'path';
import { eslint } from 'rollup-plugin-eslint';
import sourceMaps from 'rollup-plugin-sourcemaps';
import { terser } from 'rollup-plugin-terser';
import typescript from 'rollup-plugin-typescript2';
const pkg = require('./package.json');
const libraryName = 'Test';
export default {
input: 'packages/index.ts',
output: [
{
file: pkg.main,
name: libraryName,
format: 'umd',
sourcemap: true,
inlineDynamicImports: true,
exports: 'named',
globals: {
pako: 'pako',
'@babel/runtime-corejs3/core-js-stable/instance/for-each': '_forEachInstanceProperty',
'@babel/runtime-corejs3/core-js-stable/object/keys': '_Object$keys',
'@babel/runtime-corejs3/core-js-stable/instance/index-of': '_indexOfInstanceProperty',
'@babel/runtime-corejs3/core-js-stable/instance/splice': '_spliceInstanceProperty',
'@babel/runtime-corejs3/core-js-stable/instance/find-index': '_findIndexInstanceProperty',
'@babel/runtime-corejs3/core-js-stable/instance/map': '_mapInstanceProperty',
'@babel/runtime-corejs3/core-js-stable/parse-int': '_parseInt',
'@babel/runtime-corejs3/core-js-stable/instance/some': '_someInstanceProperty',
'@babel/runtime-corejs3/core-js-stable/set-timeout': '_setTimeout',
'@babel/runtime-corejs3/core-js-stable/instance/fill': '_fillInstanceProperty',
'@babel/runtime-corejs3/core-js-stable/instance/slice': '_sliceInstanceProperty',
'@babel/runtime-corejs3/core-js-stable/instance/filter': '_filterInstanceProperty',
'@babel/runtime-corejs3/core-js-stable/instance/concat': '_concatInstanceProperty'
}
},
{
file: pkg.module,
format: 'es',
inlineDynamicImports: true,
sourcemap: true,
exports: 'named',
globals: {
pako: 'pako'
}
}
],
external: [],
watch: {
include: 'packages/**'
},
plugins: [
alias({
entries: [
{
find: 'js-monitor-sdk',
replacement: path.resolve(__dirname, './packages/types')
}
]
}),
json(),
eslint({
throwOnError: false,
include: ['packages/**/*.ts'],
exclude: ['node_modules/**', 'lib/**']
}),
typescript({ useTsconfigDeclarationDir: true }),
babel({
exclude: 'node_modules',
extensions: ['.ts'],
babelHelpers: 'runtime',
presets: [
[
'@babel/preset-env',
{
useBuiltIns: 'usage',
corejs: {
version: 3,
proposals: true
}
}
]
],
plugins: [
'@babel/proposal-class-properties',
'@babel/proposal-object-rest-spread',
[
'@babel/plugin-transform-runtime',
{
useESModules: true,
corejs: 3 // 指定 runtime-corejs 的版本,目前有 2 3 两个版本
}
]
]
}),
commonjs(),
nodeResolve({
browser: true
}),
sourceMaps(),
terser({
compress: {
// remove console.log
// pure_funcs: ['console.log'],
},
output: {
// add comment on the top
preamble: `/* js-monitor-sdk- v${pkg.version} - ${new Date()} **/`
}
})
]
};