-
Notifications
You must be signed in to change notification settings - Fork 2
/
rollup.config.mjs
49 lines (44 loc) · 1.17 KB
/
rollup.config.mjs
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
import typescript from '@rollup/plugin-typescript';
import json from '@rollup/plugin-json';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import license from 'rollup-plugin-license';
import commonjs from '@rollup/plugin-commonjs';
import fs from 'fs';
const packageJson = JSON.parse(fs.readFileSync('./package.json').toString());
const TERSER_CONFIG = {
output: {
comments: false,
},
};
const LICENSE_CONFIG = {
banner: {
commentStyle: 'ignored',
content: `exactnumber v${packageJson.version} (https://www.npmjs.com/package/exactnumber)
(c) Dani Biro
@license MIT`,
},
};
const getBundleConfig = (minified = false) => ({
input: 'src/index.ts',
output: [
{
file: `dist/index.umd${minified ? '.min' : ''}.js`,
name: 'exactnumber',
format: 'umd',
},
{
file: `dist/index.esm${minified ? '.min' : ''}.js`,
format: 'es',
},
],
plugins: [
nodeResolve(),
commonjs(),
json(),
typescript(),
...(minified ? [terser(TERSER_CONFIG)] : []),
license(LICENSE_CONFIG),
],
});
export default [getBundleConfig(false), getBundleConfig(true)];