-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.ts
59 lines (56 loc) · 1.43 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
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 { 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/page-visibility
* (c) 2020-${new Date().getFullYear()} BiYuqi
* Released under the MIT License.
* https://github.com/ifakejs/page-visibility
*/`
export default {
input: './src/index.ts',
output: [
{
file: pkg.main,
format: 'umd',
name: 'IFPageVisible',
exports: 'named',
footer:
'if(typeof window !== "undefined" && window.IFPageVisible) { \n' +
' window.IFPageVisible = window.IFPageVisible.pageVisibility;\n}',
banner
},
{
file: pkg.module,
format: 'es',
banner
}
],
external: [...Object.keys(pkg.dependencies)],
plugins: [
nodeResolve(),
commonjs(),
babel({
babelHelpers: 'runtime',
exclude: /node_modules/
}),
json(),
!isDev &&
terser({
format: {
comments: function (_, comment) {
// Only the current copyright information is retained
return /@ifake/i.test(comment.value)
}
}
}),
typescript({
tsconfig: './tsconfig.json'
})
]
}