forked from CCGE-BOADICEA/pedigreejs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrollup.config.cjs
More file actions
66 lines (56 loc) · 1.59 KB
/
rollup.config.cjs
File metadata and controls
66 lines (56 loc) · 1.59 KB
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
// rollup.config.cjs
const { babel } = require('@rollup/plugin-babel');
const terser = require('@rollup/plugin-terser');
const postcss = require('rollup-plugin-postcss');
const nodeResolve = require('@rollup/plugin-node-resolve');
const commonjs = require('@rollup/plugin-commonjs');
const pkg = require('./package.json');
const version = pkg.version;
// Determine format from environment variable
const format = process.env.FORMAT || 'iife';
const isMin = process.env.MIN === 'true'; // optional flag for minified
const d = new Date();
let year = d.getFullYear();
const banner = `/*!
* © ${year} University of Cambridge
* pedigreejs v${version}
* ${pkg.homepage}
* License: ${pkg.license}
*/`;
// Determine output filename
let file;
if (format === 'iife') {
file = isMin
? `build/pedigreejs.v${version}.min.js` // minified
: `build/pedigreejs.v${version}.js`; // unminified
} else if (format === 'es') {
file = isMin
? `build/pedigreejs.v${version}.es.min.js`
: `build/pedigreejs.v${version}.es.js`
} else if (format === 'cjs') {
file = `build/pedigreejs.v${version}.cjs.js`;
}
const externalLibs = ['jquery', 'd3'];
module.exports = {
input: 'es/index.js',
external: externalLibs,
output: {
file,
format,
name: 'pedigreejs',
sourcemap: true,
banner,
// REQUIRED for IIFE/UMD only
globals: {
jquery: '$',
d3: 'd3'
}
},
plugins: [
nodeResolve({ browser: true }),
commonjs(),
babel({ babelHelpers: 'bundled', sourceMap: true }),
postcss({ extract: true, minimize: true }),
...(isMin ? [terser()] : [])
]
};