-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
66 lines (62 loc) · 1.72 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
import resolve from 'rollup-plugin-node-resolve'
import babel from 'rollup-plugin-babel'
import replace from 'rollup-plugin-replace'
import terser from '@rollup/plugin-terser'
import { sizeSnapshot } from 'rollup-plugin-size-snapshot'
import visualizer from 'rollup-plugin-visualizer'
// TODO: Добавить все скрипты
const format = process.env.FORMAT === 'cjs' ? 'cjs' : 'iife',
dev = (process.env.NODE_ENV !== 'production'),
tokens = {
__CLOCKSELECTOR__: '.clock',
__CLOCKINTERVAL__: 1000,
__CLOCKFORMAT__: 'formatHMS'
}
const plugins = () => [
resolve({
...tokens,
extensions: ['.jsx', '.js'],
}),
babel({
exclude: './node_modules/**'
}),
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
__buildDate__: () => JSON.stringify(new Date()),
__buildVersion: 15,
}),
sizeSnapshot(),
terser({
ecma: 2015,
mangle: { toplevel: true },
compress: {
toplevel: true,
drop_console: !dev,
drop_debugger: !dev
},
output: { quote_style: 1 }
}),
visualizer()
]
export default [
{
input: 'src/index.js',
output: [{ file: 'dist/index.module.js', format: format }],
plugins: plugins(),
},
{
input: 'src/profile.js',
output: [{ file: 'dist/profile.module.js', format: format }],
plugins: plugins(),
},
{
input: 'src/auth.js',
output: [{ file: 'dist/auth.module.js', format: format }],
plugins: plugins(),
},
{
input: 'src/chat.js',
output: [{ file: 'dist/chat.module.js', format: format }],
plugins: plugins(),
}
];