-
Notifications
You must be signed in to change notification settings - Fork 99
/
Copy pathrollup.config.js
76 lines (70 loc) · 2 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
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import ignore from 'rollup-plugin-ignore';
import { terser } from 'rollup-plugin-terser';
import postcss from 'rollup-plugin-postcss';
import sourcemaps from 'rollup-plugin-sourcemaps';
import typescript from '@rollup/plugin-typescript';
import filesize from 'rollup-plugin-filesize';
import pkg from './package.json';
const input = 'src/index.tsx';
const isProduction = !process.env.IS_DEVELOPMENT;
const sourcemap = !isProduction;
const clearScreen = { watch: { clearScreen: false } };
const external = [
...Object.keys(pkg.peerDependencies || {}),
(id) => /^react$|^react-dom$|^@babel\/runtime/.test(id),
];
const plugins = [
ignore(['fs', 'net', 'react', 'react-dom', 'prop-types', 'PropTypes']),
resolve({
include: ['node_modules/**'],
}),
typescript({ sourceMap: false, tsconfig: './tsconfig.json' }),
commonjs(),
postcss({
extract: 'styles.css',
modules: false,
minimize: true,
use: ['sass'],
}),
!isProduction && sourcemaps(),
isProduction && terser(),
filesize(),
].filter(Boolean);
export default [
// browser-friendly UMD build
{
input,
output: {
name: 'react-horizontal-scrolling-menu',
file: pkg.unpkg,
format: 'umd',
sourcemap,
globals: {
react: 'React',
'react-dom': 'ReactDOM',
'prop-types': 'PropTypes',
},
},
plugins,
external,
...clearScreen,
},
// CommonJS (for Node) and ES module (for bundlers) build.
// (We could have three entries in the configuration array
// instead of two, but it's quicker to generate multiple
// builds from a single configuration where possible, using
// an array for the `output` option, where we can specify
// `file` and `format` for each target)
{
input,
plugins,
external,
output: [
// { file: pkg.main, format: 'cjs', sourcemap },
{ file: pkg.module, format: 'es', sourcemap },
],
...clearScreen,
},
];