forked from zakjan/pixi-graph
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrollup.config.js
49 lines (47 loc) · 1.35 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
import pkg from './package.json';
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2';
import visualizer from 'rollup-plugin-visualizer';
import { terser } from 'rollup-plugin-terser';
import dts from 'rollup-plugin-dts';
const bundle = (format, filename, options = {}) => ({
input: 'src/index.ts',
output: {
file: filename,
format: format,
name: 'PixiGraph',
sourcemap: true,
},
external: [...Object.keys(pkg.peerDependencies), ...(!options.resolve ? Object.keys(pkg.dependencies) : [])],
plugins: [
...(options.resolve ? [resolve({ preferBuiltins: false })] : []),
commonjs(),
typescript({
typescript: require('typescript'),
clean: options.stats,
}),
...(options.minimize ? [terser()] : []),
...(options.stats
? [
visualizer({
filename: filename + '.stats.html',
}),
]
: []),
],
});
export default [
bundle('cjs', pkg.main),
bundle('es', pkg.module),
bundle('umd', 'dist/pixi-graph.umd.min.js'.replace('.min', ''), { resolve: true, stats: true }),
bundle('umd', 'dist/pixi-graph.umd.min.js', { resolve: true, minimize: true }),
{
input: 'src/index.ts',
output: {
file: pkg.types,
format: 'es',
},
plugins: [dts()],
},
];