-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
37 lines (34 loc) · 1.03 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
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import typescript from '@rollup/plugin-typescript';
import pkg from './package.json' with { type: 'json' };
const name = pkg.name
.replace(/^(@\S+\/)?(\S+)/, '$3')
.replace(/^\w/, (m) => m.toUpperCase())
.replace(/-\w/g, (m) => m[1].toUpperCase());
const production = !process.env.ROLLUP_WATCH;
const config = (browser = true) => {
let output = browser ? pkg.exports['.']['browser'] : pkg.exports['.']['default'];
return {
input: `src/${browser ? 'browser' : 'node'}.ts`,
output: [
{ file: output.import, format: 'es' },
{ file: output.require || output.default, format: 'umd', name }
],
plugins: [
resolve({ preferBuiltins: !browser, browser }),
commonjs(),
typescript({
sourceMap: !production,
inlineSources: !production
}),
production && terser()
],
watch: {
clearScreen: false
}
};
};
// console.log(config())
export default [config(true), config(false)];