forked from clappr/clappr-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rollup.config.js
87 lines (81 loc) · 2.36 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
84
85
86
87
import alias from '@rollup/plugin-alias'
import babel from '@rollup/plugin-babel'
import commonjs from '@rollup/plugin-commonjs'
import jsonReader from '@rollup/plugin-json'
import replace from '@rollup/plugin-replace'
import resolve from '@rollup/plugin-node-resolve'
import html from 'rollup-plugin-html'
import namedDirectory from 'rollup-plugin-named-directory'
import postcss from 'rollup-plugin-postcss'
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'
const dev = !!process.env.DEV
const analyzeBundle = !!process.env.ANALYZE_BUNDLE
const minimize = !!process.env.MINIMIZE
const postcssOptions = {
use: [
['sass', {
includePaths: ['src/base/scss']
}]
],
inject: false,
}
const aliasPluginOptions = { entries: { 'clappr-zepto': 'node_modules/clappr-zepto/zepto.js', '@': __dirname + '/src' } }
const replacePluginOptions = { VERSION: JSON.stringify(pkg.version) }
const babelPluginOptions = { babelHelpers: 'bundled', exclude: 'node_modules/**' }
const servePluginOptions = { contentBase: ['dist', 'public'], host: '0.0.0.0', port: '8080' }
const livereloadPluginOptions = { watch: ['dist', 'public'] }
const visualizePluginOptions = { open: true, filename: './public/stats.html' }
const plugins = [
jsonReader(),
alias(aliasPluginOptions),
replace(replacePluginOptions),
resolve(),
commonjs(),
babel(babelPluginOptions),
namedDirectory(),
html(),
postcss(postcssOptions),
size(),
filesize(),
dev && serve(servePluginOptions),
dev && livereload(livereloadPluginOptions),
analyzeBundle && visualize(visualizePluginOptions)
]
const mainBundle = {
input: 'src/main.js',
output: [
{
exports: 'named',
name: 'Clappr',
file: pkg.main,
format: 'umd',
sourcemap: true,
},
minimize && {
exports: 'named',
name: 'Clappr',
file: 'dist/clappr-core.min.js',
format: 'iife',
sourcemap: true,
plugins: terser(),
}
],
plugins,
}
const esmBundle = {
input: 'src/main.js',
output: {
exports: 'named',
name: 'Clappr',
file: pkg.module,
format: 'esm',
},
plugins,
}
export default [mainBundle, esmBundle]