-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.ts
64 lines (61 loc) · 1.64 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { nodeResolve } from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import babel from '@rollup/plugin-babel'
import json from '@rollup/plugin-json'
import replace from '@rollup/plugin-replace'
import { terser } from 'rollup-plugin-terser'
import typescript from '@rollup/plugin-typescript'
const pkg = require('./package.json')
const isDev = process.env.NODE_ENV !== 'production'
const banner = `/*!
* @ifake/signature
* (c) 2020-${new Date().getFullYear()} BiYuqi
* Released under the MIT License.
* https://github.com/ifakejs/signature
*/`
export default {
input: './src/index.ts',
output: [
{
file: pkg.main,
format: 'umd',
name: 'IfSignature',
exports: 'named',
footer:
'if(typeof window !== "undefined" && window.IfSignature) { \n' +
' window.IfSignature = window.IfSignature.IfSignature;\n}',
banner
},
{
file: pkg.module,
format: 'es',
banner
}
],
external: [...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {})],
plugins: [
nodeResolve(),
commonjs(),
babel({
babelHelpers: 'runtime',
exclude: /node_modules/
}),
replace({
preventAssignment: true,
'process.env.NODE_ENV': isDev ? JSON.stringify('development') : JSON.stringify('production')
}),
json(),
!isDev &&
terser({
format: {
comments: (_, comment) => {
// Only the current copyright information is retained
return /@ifake/i.test(comment.value)
}
}
}),
typescript({
tsconfig: './tsconfig.json'
})
]
}