-
Notifications
You must be signed in to change notification settings - Fork 149
/
rollup.config.js
59 lines (56 loc) · 1.45 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
// @ts-check
import { babel } from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import terser from '@rollup/plugin-terser';
import del from 'rollup-plugin-delete';
import typescript from 'rollup-plugin-typescript2';
import packageJson from './package.json';
export function kebabCaseToPascalCase(string = '') {
return string.replace(/(^\w|-\w)/g, (replaceString) =>
replaceString.replace(/-/, '').toUpperCase(),
);
}
/**
* @type {import('rollup').InputPluginOption}
*/
export const commonPlugins = [
nodeResolve({ browser: true, preferBuiltins: false }),
commonjs(),
json(),
babel({
babelHelpers: 'bundled',
plugins: ['@babel/plugin-transform-object-rest-spread'],
presets: ['@babel/preset-env'],
extensions: ['.js', '.ts', '.mjs'],
babelrc: false,
}),
];
/**
* @type {import('rollup').RollupOptions}
*/
export default {
input: 'src/index.ts',
output: [
{
file: `dist/${packageJson.name}.esm.mjs`,
format: 'es',
strict: true,
sourcemap: true,
},
{
file: `dist/${packageJson.name}.umd.js`,
format: 'umd',
strict: true,
sourcemap: true,
name: kebabCaseToPascalCase(packageJson.name),
plugins: [terser()],
},
],
plugins: [
del({ targets: 'dist/*' }),
typescript({ tsconfig: './tsconfig.json' }),
...commonPlugins
],
};