-
-
Notifications
You must be signed in to change notification settings - Fork 47
/
rollup.config.js
85 lines (81 loc) · 2.42 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import babel from '@rollup/plugin-babel';
import { terser } from 'rollup-plugin-terser';
import del from 'rollup-plugin-delete';
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
import typescript from 'rollup-plugin-typescript2';
import postcss from 'rollup-plugin-postcss';
import pkg from './package.json';
// https://stackoverflow.com/a/65978156/1189762
// see package.json "type": "module"
// https://stackoverflow.com/a/63216984/1189762
// see babel.config.cjs instead of .js
// https://github.com/storybookjs/storybook/issues/11587#issuecomment-898604266
// see .storybook/package.json
const babelConfig = require('./babel.config.cjs');
const extensions = ['.js', '.jsx', '.ts', '.tsx'];
export default {
input: {
main: './src/index.ts',
types: './src/types/index.ts',
common: './src/common/index.ts',
table: './src/table/index.ts',
compact: './src/compact/index.ts',
virtualized: './src/virtualized/index.ts',
// features
theme: './src/theme/index.ts',
sort: './src/sort/index.ts',
select: './src/select/index.ts',
tree: './src/tree/index.ts',
pagination: './src/pagination/index.ts',
// themes
baseline: './src/baseline/index.ts',
mantine: './src/mantine/index.ts',
['chakra-ui']: './src/chakra-ui/index.ts',
['material-ui']: './src/material-ui/index.ts',
},
output: [
// ES module version, for modern browsers
{
name: '@table-library/react-table-library',
dir: `${__dirname}/lib`,
format: 'es',
sourcemap: true,
entryFileNames: '[name].js',
// preserveModules: true,
},
// SystemJS version, for older browsers
// {
// dir: `${__dirname}/lib/nomodule`,
// format: 'system',
// sourcemap: true,
// },
],
external: [...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {})],
plugins: [
del({ targets: 'lib/*' }),
peerDepsExternal(),
postcss({
modules: true,
}),
resolve({ extensions, preferBuiltins: false }),
typescript({
typescript: require('typescript'),
clean: true,
}),
babel({
babelHelpers: 'runtime',
exclude: 'node_modules/**',
extensions,
...babelConfig,
}),
commonjs({
sourceMap: true,
exclude: 'src/**',
}),
terser({
module: true,
}),
],
};