-
Notifications
You must be signed in to change notification settings - Fork 28
/
rollup.config.js
87 lines (79 loc) · 1.85 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
import {terser} from 'rollup-plugin-terser'
import typescript from 'rollup-plugin-typescript2'
import pluginCommonjs from "@rollup/plugin-commonjs";
import replace from "rollup-plugin-replace";
import pkg from './package.json'
const banner = `
/*
${pkg.name} v${pkg.version}
${pkg.repository.url}
Copyright (c) ${pkg.author.name}
This source code is licensed under the ${pkg.license} license found in the
LICENSE file in the root directory of this source tree.
@bannerend*/
`
const external = [...Object.keys(pkg.dependencies || {})]
const plugins = [
typescript({
typescript: require('typescript'),
}),
pluginCommonjs({
extensions: [".js", ".ts"]
}),
replace({
__REPLACE_VERSION__: pkg.version,
})
]
if(!process.env.ROLLUP_WATCH)
plugins.push(terser({
format: {
// only permit banner comment
comments: function (node, comment) {
if (comment.type === 'comment2') {
// multiline comment
return /@bannerend/i.test(comment.value)
}
},
},
}))
export default [
// Create CommonJS and ES Module for Node and modern browsers
{
input: 'src/index.ts',
output: [
{
file: pkg.main,
format: 'cjs',
banner,
exports: "default"
},
{
file: pkg.module,
format: 'es', // the preferred format
banner,
},
{
file: pkg.browser,
format: 'umd',
name: 'DSA', // the global which can be used in a browser
banner,
}
],
external,
plugins,
},
// Create iife with DSA as default export
// {
// input: 'src/index.default.ts',
// output: [
// {
// file: pkg.browser,
// format: 'iife',
// name: 'DSA', // the global which can be used in a browser
// banner,
// },
// ],
// external,
// plugins,
// },
]