-
Notifications
You must be signed in to change notification settings - Fork 88
/
rollup.config.js
77 lines (70 loc) · 1.65 KB
/
rollup.config.js
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
import ts from 'rollup-plugin-typescript2'
import terser from '@rollup/plugin-terser'
import pkg from './package.json' with { type: 'json' }
const banner =
'/*!' +
'\n * qrcode.vue v' +
pkg.version +
'\n * ' +
pkg.description +
'\n * © 2017-PRESENT' +
' @scopewu(https://github.com/scopewu)' +
'\n * MIT License.' +
'\n */'
const sourcemap = false
function createEntry(options) {
/** @type import('rollup').RollupOptions */
const config = {
input: 'src/index.ts',
external: ['vue'],
output: {
name: 'QrcodeVue',
file: options.file,
format: options.format,
exports: 'named',
globals: {
vue: 'Vue'
},
banner,
indent: false,
sourcemap,
},
plugins: [
ts({
check: options.format === 'es',
tsconfigOverride: {
compilerOptions: {
declaration: options.format === 'es',
},
exclude: ['src', 'example'],
}
}),
],
}
if (Array.isArray(options.plugins)) {
config.plugins.push(...options.plugins)
}
return config
}
const browserPlugins = [
terser({
format: {
comments: function (node, comment) {
const { value, type } = comment
return type === 'comment2' && /^!/.test(value)
},
},
compress: {
pure_getters: true,
unsafe: true,
unsafe_comps: true,
drop_console: true,
},
}),
]
export default [
createEntry({ format: 'cjs', file: pkg.main }),
createEntry({ format: 'es', file: pkg.module }),
createEntry({ format: 'umd', file: pkg.browser, }),
createEntry({ format: 'umd', file: pkg.unpkg, plugins: browserPlugins }),
]