-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.js
61 lines (53 loc) · 1.41 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
import ts from 'rollup-plugin-typescript2'
import prettier from 'rollup-plugin-prettier'
import { terser } from 'rollup-plugin-terser'
import { version, name } from './package.json'
const formats = ['umd', 'umd.min']
const copyright =
'Copyright (c) 2022-present Eyelly Wu <https://github.com/eyelly-wu>'
const banner = `/*
* ${name}
* v${version}
* ${new Date().toLocaleString()}
* ${copyright}
*/`
const minBanner = `// ${name} v${version} ${new Date().toLocaleString()} ${copyright}`
export default formats.map((format, index) => {
const isLast = index === formats.length - 1
let pluginsExtra = []
const suffix = format.split('.')[1]
if (format.includes('.')) {
pluginsExtra.push(
terser({
format: {
comments: /i18n-pro/,
},
}),
)
}
return {
input: 'src/lib/index.ts',
output: {
file: `dist/src/lib/index${suffix ? '.' + suffix : ''}.js`,
format: format.includes('.') ? format.split('.')[0] : format,
banner: suffix ? minBanner : banner,
name: 'i18nPro',
},
plugins: [
ts({
useTsconfigDeclarationDir: isLast,
tsconfigOverride: {
compilerOptions: {
removeComments: false,
declaration: isLast,
declarationDir: 'dist',
module: 'ESNext',
target: 'es5',
},
},
}),
prettier(),
...pluginsExtra,
],
}
})