-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathrollup.config.js
41 lines (35 loc) · 1.21 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
/*
* @since 2020-11-03 13:16:07
* @author acrazing <[email protected]>
*/
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import sourceMaps from 'rollup-plugin-sourcemaps';
import { terser } from 'rollup-plugin-terser';
import typescript from 'rollup-plugin-typescript2';
const packageJson = require('./package.json');
const deps = Object.keys(packageJson.dependencies).concat(Object.keys(packageJson.devDependencies));
const id = packageJson.name.split('/').pop();
const options = (format, index = 'index') => ({
input: `src/${index}.ts`,
output: {
file: `dist/${id}${index === 'index' ? '' : '-' + index}.${format}.js`,
format,
sourcemap: true,
name: id.charAt(0).toUpperCase() + id.substring(1),
plugins: format === 'umd' ? [terser({ format: { comments: false } })] : [],
},
external: format === 'umd' ? [] : deps,
plugins: [
typescript({
tsconfigOverride: {
compilerOptions: { module: 'esnext' },
exclude: ['src/**/*.spec.ts', 'src/**/*.spec.tsx'],
},
}),
commonjs(),
resolve({ preferBuiltins: true }),
sourceMaps(),
],
});
export default [options('cjs'), options('es'), options('umd')];