-
-
Notifications
You must be signed in to change notification settings - Fork 83
/
rollup.config.dist.js
52 lines (42 loc) · 1.39 KB
/
rollup.config.dist.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
/* global process Set */
import {readFileSync} from 'fs';
import node from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
var pkg = JSON.parse(readFileSync('package.json', 'utf8'));
var dependencies = pkg => {
var deps = Object.keys(pkg.dependencies || {}).concat(Object.keys(pkg.peerDependencies || {}));
return Array.from(new Set(deps.concat(deps.flatMap(dependency => (
dependencies(JSON.parse(readFileSync(`node_modules/${dependency}/package.json`, 'utf8')))
)))));
};
var banner = `/**
* Fluture bundled; version ${process.env.VERSION || `${pkg.version} (dirty)`}
*/
`;
var footer = `/** Fluture license
${readFileSync('./LICENSE')}*/
${dependencies(pkg).map(dependency => `/** ${dependency} license
${readFileSync(`./node_modules/${dependency}/LICENSE`)}*/`).join('\n\n')}`;
var typeref = `/// <reference types="https://cdn.jsdelivr.net/gh/fluture-js/Fluture@${
process.env.VERSION || pkg.version
}/index.d.ts" />`;
export default [{
input: 'index.cjs.js',
plugins: [node(), commonjs({include: 'node_modules/**'})],
output: {
banner: banner,
footer: footer,
format: 'iife',
name: 'Fluture',
file: 'dist/bundle.js',
},
}, {
input: 'index.js',
plugins: [node(), commonjs({include: 'node_modules/**'})],
output: {
banner: `${banner}\n${typeref}\n`,
footer: footer,
format: 'es',
file: 'dist/module.js',
},
}];