-
Notifications
You must be signed in to change notification settings - Fork 1
/
rollup.config.js
80 lines (74 loc) · 1.98 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
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import replace from '@rollup/plugin-replace';
import svg from 'rollup-plugin-svg';
import json from '@rollup/plugin-json';
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 { terser } from 'rollup-plugin-terser';
import analyze from 'rollup-plugin-analyzer';
import pkg from './package.json';
import { version as clapprCoreVersion } from '@clappr/core/package.json';
import path from 'path';
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 postcssOptions = {
use: [
['sass', {
includePaths: [
path.resolve('node_modules/@clappr/core/src/base/scss')
]
}]
]
};
const plugins = [
replace({
preventAssignment: true,
values: {
VERSION: JSON.stringify(pkg.version),
CLAPPR_CORE_VERSION: JSON.stringify(clapprCoreVersion),
}
}),
commonjs(),
nodeResolve({ browser: true, preferBuiltins: true }),
babel({ exclude: 'node_modules/**', babelHelpers: 'bundled' }),
svg({ base64: true }),
json(),
postcss(postcssOptions),
dev && serve(servePluginOptions),
dev && livereload(livereloadPluginOptions),
analyzeBundle && analyze(),
];
const output = [
{
name: 'Marquee',
file: pkg.main,
format: 'umd',
sourcemap: true,
globals: { '@clappr/core': 'Clappr' },
},
minimize && {
file: 'dist/marquee.min.js',
format: 'umd',
name: 'Marquee',
sourcemap: true,
plugins: terser(),
globals: { '@clappr/core': 'Clappr' },
},
minimize && {
file: 'dist/marquee.esm.js',
format: 'esm',
name: 'Marquee',
}
];
export default {
input: 'src/index.js',
external: ['@clappr/core'],
output,
plugins,
};