Rollup example for @slorber
import nodeResolve from 'rollup-plugin-node-resolve' | |
import babel from 'rollup-plugin-babel' | |
import pkg from './package.json' | |
const mergeAll = objs => Object.assign({}, ...objs) | |
const commonPlugins = [ | |
babel({ | |
plugins: ['external-helpers'], | |
}), | |
] | |
const externals = [ | |
...Object.keys(pkg.dependencies || {}), | |
...Object.keys(pkg.peerDependencies || {}) | |
] | |
const externalPattern = new RegExp(`^(${externals.join('|')})($|/)`) | |
const configBase = { | |
input: 'src/index.js', | |
external: externals.length === 0 | |
? () => false | |
: id => externalPattern.test(id), | |
plugins: commonPlugins, | |
} | |
const webConfig = mergeAll([ | |
configBase, | |
{ output: [{ file: pkg.module, format: 'es' }, { file: pkg.main, format: 'cjs' }] }, | |
]) | |
const rnConfig = mergeAll([ | |
configBase, | |
{ | |
output: { file: pkg['react-native'], format: 'cjs' }, | |
plugins: commonPlugins.concat([ | |
nodeResolve({ extensions: ['.native.js', '.js'] }) | |
]), | |
}, | |
]) | |
export default [webConfig, rnConfig] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment