-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.js
63 lines (58 loc) · 1.82 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
60
61
62
63
import { createBabelInputPluginFactory } from '@rollup/plugin-babel'
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import serve from 'rollup-plugin-serve'
import filesize from 'rollup-plugin-filesize'
import size from 'rollup-plugin-sizes'
import visualize from 'rollup-plugin-visualizer'
import { terser } from 'rollup-plugin-terser'
import pkg from './package.json'
import babelConfig from './babel.config.json'
const babelPluginForUMDBundle = createBabelInputPluginFactory()
const babelPluginForESMBundle = createBabelInputPluginFactory()
const babelPluginOptions = { ...babelConfig, exclude: 'node_modules/**', babelHelpers: 'bundled' }
const plugins = [
size(),
filesize(),
!!process.env.DEV && serve({ contentBase: ['dist', 'public'], host: '0.0.0.0', port: '8080' }),
!!process.env.ANALYZE_BUNDLE && visualize({ open: true }),
]
const mainBundle = {
input: 'src/queue.js',
external: ['@clappr/core'],
output: [
{
name: 'QueuePlugin',
file: pkg.main,
format: 'umd',
globals: { '@clappr/core': 'Clappr' },
},
!!process.env.MINIMIZE && {
name: 'QueuePlugin',
file: 'dist/clappr-queue-plugin.min.js',
format: 'umd',
globals: { '@clappr/core': 'Clappr' },
plugins: terser(),
},
],
plugins: [babelPluginForUMDBundle(babelPluginOptions), resolve(), commonjs(), ...plugins],
}
const esmBundle = {
input: 'src/queue.js',
external: ['@clappr/core', /@babel\/runtime/],
output: {
name: 'QueuePlugin',
file: pkg.module,
format: 'esm',
globals: { '@clappr/core': 'Clappr' },
},
plugins: [
babelPluginForESMBundle({
...babelPluginOptions,
plugins: ['@babel/plugin-transform-runtime'],
babelHelpers: 'runtime',
}),
...plugins,
],
}
export default [mainBundle, esmBundle]