-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
63 lines (56 loc) · 1.31 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
import typescript from 'rollup-plugin-typescript2';
import pluginCommonjs from '@rollup/plugin-commonjs';
import replace from 'rollup-plugin-replace';
import pkg from './package.json' assert { type: 'json' };
import json from '@rollup/plugin-json';
import terser from '@rollup/plugin-terser';
import dotenv from 'dotenv';
dotenv.config();
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 plugins = [
typescript(),
pluginCommonjs({
extensions: ['.js', '.ts'],
}),
replace({
__REPLACE_VERSION__: pkg.version,
}),
json(),
];
if (process.env.NODE_ENV === 'production') {
plugins.push(terser());
}
export default [
// Create CommonJS and ES Module for Node and modern browsers
{
input: 'src/index.ts',
output: [
{
file: pkg.main,
format: 'cjs',
banner,
exports: 'auto',
},
{
file: pkg.module,
format: 'es', // ES Module format
banner,
},
{
file: pkg.browser,
format: 'umd',
name: 'PNS', // the global which can be used in a browser
banner,
},
],
plugins,
},
];