forked from j-em/react-authorize-net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrollup.config.js
97 lines (90 loc) · 2.53 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
86
87
88
89
90
91
92
93
94
95
96
97
// @ts-check
import { DEFAULT_EXTENSIONS } from '@babel/core'
import babel from 'rollup-plugin-babel'
import commonjs from 'rollup-plugin-commonjs'
import filesize from 'rollup-plugin-filesize'
import nodeResolve from 'rollup-plugin-node-resolve'
import replace from 'rollup-plugin-replace'
import sourcemaps from 'rollup-plugin-sourcemaps'
import includePaths from 'rollup-plugin-includepaths'
import postcss from 'rollup-plugin-postcss'
import url from "rollup-plugin-url"
import { uglify } from 'rollup-plugin-uglify'
import pkg from './package.json'
const getExternal = (bundleType) => {
const peerDependencies = Object.keys(pkg.peerDependencies)
const dependencies = Object.keys(pkg.dependencies)
const makeExternalPredicate = externals => {
if (externals.length === 0) {
return () => false
}
const pattern = new RegExp(`^(${externals.join('|')})($|/)`)
return id => pattern.test(id)
}
return makeExternalPredicate([...peerDependencies, ...dependencies])
}
const getBabelConfig = () => {
const options = {
babelrc: false,
exclude: 'node_modules/**',
presets: [
['@babel/env', { loose: true, modules: false }],
'@babel/react',
'@babel/typescript'
],
plugins: [
['@babel/proposal-class-properties', { loose: true }],
['transform-react-remove-prop-types', { mode: 'wrap' }],
['babel-plugin-styled-components'],
'@babel/transform-runtime'
],
runtimeHelpers: true,
extensions: [...DEFAULT_EXTENSIONS, '.ts', '.tsx']
}
return options
}
const config = {
input: './src/index.ts',
external: getExternal(),
output: {
file: 'dist/react-authorize-net.js',
format: 'es',
name: 'react-authorize-net',
sourcemap: true
},
plugins: [
nodeResolve(),
url({ limit: 16 * 1024, include: ["**/*.woff2"] }),
commonjs({
include: 'node_modules/**',
namedExports: {
'react-is': ['isElement', 'isValidElementType', 'ForwardRef'],
'node_modules/prop-types/index.js': [
'any',
'array',
'arrayOf',
'bool',
'element',
'exact',
'func',
'instanceOf',
'node',
'number',
'object',
'objectOf',
'oneOf',
'oneOfType',
'shape',
'string',
'symbol'
]
}
}),
postcss({ plugins: [], inject: false }),
babel(getBabelConfig()),
includePaths({path: './src', extensions: ['.tsx', '.ts']}),
sourcemaps(),
filesize()
]
}
export default config