-
Notifications
You must be signed in to change notification settings - Fork 3
/
rollup.config.js
48 lines (43 loc) · 1.35 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
import { resolve } from 'path';
import pluginResolve from '@rollup/plugin-node-resolve';
import { terser } from 'rollup-plugin-terser';
import { babel } from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import typescript from '@rollup/plugin-typescript';
import Package from './package.json';
const extensions = ['.mjs', '.tsx', '.ts', '.js', '.json'];
function createBuild(input, format) {
return {
input: resolve(__dirname, `src/${input}.ts`),
output: {
file: `${input}.${format === 'esm' ? 'mjs' : 'js'}`,
format,
plugins: [terser()],
sourcemap: true,
},
plugins: [
pluginResolve({ extensions }),
commonjs({ extensions: ['.js'] }),
typescript({
tsconfig: './tsconfig.build.json',
}),
babel({
babelHelpers: 'bundled',
extensions,
skipPreflightCheck: true,
babelrc: false,
...require('./babel.config').generateConfig({
isEsm: format === 'esm',
}),
}),
].filter(Boolean),
external: ['forest/forest.mjs', 'effector/effector.mjs'].concat(
Object.keys(Package.peerDependencies),
Object.keys(Package.dependencies),
),
};
}
const inputs = ['index'];
const formats = ['cjs', 'esm'];
const config = inputs.flatMap((i) => formats.map((f) => createBuild(i, f)));
export default config;