generated from toastyboost/rollup-starter
-
Notifications
You must be signed in to change notification settings - Fork 6
/
rollup.config.js
43 lines (38 loc) · 1.21 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
const { resolve } = require('path');
const pluginResolve = require('@rollup/plugin-node-resolve');
const terser = require('@rollup/plugin-terser');
const { babel } = require('@rollup/plugin-babel');
const commonjs = require('@rollup/plugin-commonjs');
const typescript = require('rollup-plugin-typescript2');
const babelConfig = require('./babel.config');
const extensions = ['.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: [
commonjs(),
pluginResolve({ extensions }),
typescript({ useTsconfigDeclarationDir: true }),
babel({
exclude: 'node_modules/**',
babelHelpers: 'bundled',
extensions,
skipPreflightCheck: true,
babelrc: false,
...babelConfig.generateConfig({
isEsm: format === 'esm',
}),
}),
],
};
}
const inputs = ['index'];
const formats = ['cjs', 'esm'];
const configs = inputs.map((input) => formats.map((format) => createBuild(input, format))).flat();
module.exports = configs;