This repository has been archived by the owner on Jun 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
92 lines (87 loc) · 1.81 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
91
92
import pkg from './package.json'
import camelCase from 'lodash.camelcase'
import startCase from 'lodash.startcase'
import buble from 'rollup-plugin-buble'
import sourcemaps from 'rollup-plugin-sourcemaps'
import { uglify } from 'rollup-plugin-uglify'
import { terser } from 'rollup-plugin-terser'
const input = `compiled/${pkg.name}.js`
const name = camelCase(pkg.name)
const outputFile = format => `dist/${pkg.name}.${format}.js`
const banner = `/*!
* ${startCase(pkg.name)}. ${pkg.description}.
* ${pkg.homepage}
* Copyright (c) 2015-${(new Date()).getFullYear()} ${pkg.author.name}
* Licensed under the ${pkg.license} license
* Version: ${pkg.version}
*/`
const bannerMin = `/*! ${startCase(pkg.name)} v${pkg.version} | ` +
`Copyright (c) 2015-${(new Date()).getFullYear()} ${pkg.author.name} | ${pkg.license} | ${pkg.homepageShort} */`
export default [
// UMD
{
input,
output: {
file: outputFile('umd'),
name,
format: 'umd',
sourcemap: true,
banner,
},
plugins: [
buble(),
sourcemaps(),
],
},
// UMD minified
{
input,
output: {
file: outputFile('umd.min'),
name,
format: 'umd',
sourcemap: false,
banner: bannerMin,
},
plugins: [
buble(),
uglify({
output: {
comments: /^!/,
},
}),
],
},
// ES Module
{
input,
output: {
file: outputFile('esm'),
name,
format: 'esm',
sourcemap: true,
banner,
},
plugins: [
sourcemaps(),
]
},
// ES Module minified
{
input,
output: {
file: outputFile('esm.min'),
name,
format: 'esm',
sourcemap: false,
banner: bannerMin,
},
plugins: [
terser({
output: {
comments: /^!/,
},
}),
],
},
]