import babel from '@rollup/plugin-babel'
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import peerDepsExternal from 'rollup-plugin-peer-deps-external'
import pkg from './package.json'
import postcss from 'rollup-plugin-postcss'
import resolve from '@rollup/plugin-node-resolve'
import { terser } from 'rollup-plugin-terser'

const ROLLUP_CONFIG = {
  input: './src/package.js',
  output: [
    { file: 'dist/index.js', format: 'es' },
    { file: 'dist/index.cjs.js', format: 'cjs' }
  ],
  external: Object.keys(pkg.peerDependencies),
  plugins: [
    peerDepsExternal(),
    resolve(),
    babel({
      exclude: ['node_modules/**', 'src/index.js', 'src/App.js'],
      presets: ['@babel/preset-react', '@babel/preset-env']
    }),
    json(),
    postcss(),
    commonjs(),
    terser()
  ]
}

export default ROLLUP_CONFIG
