-
Notifications
You must be signed in to change notification settings - Fork 2
/
rollup.config.js
68 lines (62 loc) · 1.55 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
const commonjs = require('rollup-plugin-commonjs');
const resolve = require('rollup-plugin-node-resolve');
const replace = require('rollup-plugin-replace');
const json = require('rollup-plugin-json');
const typescript = require('rollup-plugin-typescript2');
const pkg = require('./package.json');
function pluginsBase() {
return [
json({
preferConst: true,
}),
resolve({
mainFields: ['jsnext', 'esnext', 'module', 'main'],
}),
typescript({
tsconfig: 'tsconfig.json',
tsconfigOverride: {
compilerOptions: {
declarationMap: false,
declaration: false,
target: 'es5',
downlevelIteration: true,
},
},
}),
commonjs({
include: ['node_modules/**', 'dist/es/**', 'packages/**/node_modules/**'],
}),
replace({
ENV: JSON.stringify(process.env.NODE_ENV || 'development'),
EXPORTER_VERSION: pkg.version,
}),
];
}
function distConfig(input, file, format, pkg, tsConfig = {}) {
return {
input,
external: format !== 'iife' ? Object.keys(pkg.dependencies) : [],
output: {
name: 'Figure',
file,
format,
sourcemap: true,
globals: format === 'umd' ? {
hilo3d: 'Hilo3d'
} : {}
},
plugins: [
...pluginsBase(tsConfig)
],
};
}
const arr = [];
const file = './lib/index.ts';
arr.push(
distConfig(file, 'dist/index.esm.js', 'esm', pkg),
distConfig(file, 'dist/index.cjs.js', 'cjs', pkg),
distConfig(file, 'dist/index.umd.js', 'umd', pkg),
);
module.exports = [
...arr,
];