forked from clappr/clappr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
84 lines (79 loc) · 2.13 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import replace from '@rollup/plugin-replace'
import html from 'rollup-plugin-html'
import postcss from 'rollup-plugin-postcss'
import babel from '@rollup/plugin-babel'
import livereload from 'rollup-plugin-livereload'
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 { version as clapprCoreVersion } from '@clappr/core/package.json'
const dev = !!process.env.DEV
const analyzeBundle = !!process.env.ANALYZE_BUNDLE
const minimize = !!process.env.MINIMIZE
const servePluginOptions = { contentBase: ['dist', 'public'], host: '0.0.0.0', port: '8080' }
const livereloadPluginOptions = { watch: ['dist', 'public'] }
const visualizePluginOptions = { open: true }
const plugins = [
replace({
preventAssignment: true,
values: {
VERSION: JSON.stringify(pkg.version),
CLAPPR_CORE_VERSION: JSON.stringify(clapprCoreVersion),
}
}),
resolve(),
commonjs(),
babel({ exclude: 'node_modules/**', babelHelpers: 'bundled' }),
html(),
postcss(),
size(),
filesize(),
dev && serve(servePluginOptions),
dev && livereload(livereloadPluginOptions),
analyzeBundle && visualize(visualizePluginOptions),
]
export default [
{
input: 'src/base_bundle.js',
output: [
{
name: 'Clappr',
file: 'dist/clappr.plainhtml5.js',
format: 'umd',
sourcemap: true,
},
minimize && {
name: 'Clappr',
file: 'dist/clappr.plainhtml5.min.js',
format: 'iife',
sourcemap: true,
plugins: terser(),
}
],
plugins,
},
{
input: 'src/main.js',
output: [
{
name: 'Clappr',
file: pkg.main,
format: 'umd',
sourcemap: true,
},
minimize && {
file: 'dist/clappr.min.js',
format: 'iife',
name: 'Clappr',
sourcemap: true,
plugins: terser(),
}
],
plugins,
}
]