-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathrollup.config.mjs
36 lines (32 loc) · 1.01 KB
/
rollup.config.mjs
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
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import babel from '@rollup/plugin-babel';
import terser from '@rollup/plugin-terser';
import * as packageJson from './package.json';
const info = `/*
* ${packageJson.library}
* Version ${packageJson.version}
* ${packageJson.homepage}
*/
`;
const config = (options = {}) => ({
input: 'lib/src/index.js',
output: options.output.map((type) => ({
name: 'SidebarJS',
file: `lib/${type}/sidebarjs${options.minify ? '.min' : ''}.js`,
format: type,
exports: 'named',
banner: info,
})),
plugins: [...(options.plugins || []), options.minify ? terser() : false].filter(Boolean),
});
const plugins = [
resolve({mainFields: ['module', 'main'], browser: true}),
babel({babelHelpers: 'bundled', exclude: 'node_modules/**'}),
commonjs(),
];
export default [
config({output: ['umd', 'amd', 'cjs'], plugins}),
config({output: ['umd', 'amd', 'cjs'], plugins, minify: true}),
config({output: ['esm']}),
];