This repository has been archived by the owner on Mar 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
rollup.config.js
90 lines (85 loc) · 2.04 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
78
79
80
81
82
83
84
85
86
87
88
89
90
// rollup.config.js
import commonjs from 'rollup-plugin-commonjs';
import json from 'rollup-plugin-json';
import resolve from 'rollup-plugin-node-resolve';
import typescript from 'rollup-plugin-typescript';
import {terser} from 'rollup-plugin-terser';
import license from 'rollup-plugin-license';
import {name, version, main, module, browser, author} from './package.json';
const isProduction = process.env.NODE_ENV === 'production';
const isForLib = process.env.NODE_ENV === 'lib';
const settings = {
globals: {
lodash: 'lodash',
moment: 'moment',
tslib: 'tslib'
}
};
export default {
input: isForLib ? './scripts/lib.ts' : './src/index.ts',
output: [
{
file: isForLib ? 'dist/formula.js' : main,
name: isForLib ? 'formula' : main,
...settings,
format: isForLib ? 'iife' : 'cjs',
plugins: [
isForLib && terser()
],
strict: !isForLib,
footer: isForLib ? `var evaluate = formula.evaluate;
var momentFormat = formula.momentFormat;
var parse = formula.parse;` : '',
}
// {
// file: module,
// ...settings,
// name: name,
// format: 'es'
// },
// {
// file: browser,
// ...settings,
// name: name,
// format: 'umd'
// }
],
external: isForLib ? [] : [
'lodash',
'lodash/transform',
'lodash/groupBy',
'lodash/uniqBy',
'lodash/uniq',
'lodash/isPlainObject',
'lodash/padStart',
'lodash/upperFirst',
'lodash/capitalize',
'lodash/escape',
'lodash/truncate',
'moment',
'tslib'
],
plugins: [
json(),
resolve({
jsnext: true,
main: true,
browser: true
}),
typescript({
typescript: require('typescript')
}),
commonjs({
include: 'node_modules/**',
extensions: ['.js'],
ignoreGlobal: false,
sourceMap: false
}),
license({
banner: `
${name} v${version}
Copyright 2021<%= moment().format('YYYY') > 2021 ? '-' + moment().format('YYYY') : null %> ${author}
`
})
]
};