import babel from 'rollup-plugin-babel';
import resolve from '@rollup/plugin-node-resolve';
import external from 'rollup-plugin-peer-deps-external';
import { terser } from 'rollup-plugin-terser';
import postcss from 'rollup-plugin-postcss';
import commonjs from "@rollup/plugin-commonjs";
import json from '@rollup/plugin-json'
import nodePolyfills from 'rollup-plugin-node-polyfills';
import image from "@rollup/plugin-image"
import svg from 'rollup-plugin-svg'
import svgicons from 'rollup-plugin-svg-icons'
import copy from 'rollup-plugin-copy'
import font from "rollup-plugin-font";

export default [
  {
    input: './src/index.js',
    output: [
      {
        file: './dist/index.js',
        format: 'cjs',
      },
      {
        file: './dist/index.es.js',
        format: 'es',
        exports: 'named',
      }
    ],
    inlineDynamicImports: true,
    plugins: [
      postcss({
        plugins: [],
        minimize: true,
      }),
      babel({
        exclude: 'node_modules/**',
        presets: ['@babel/preset-env' , 
                 '@babel/preset-react'
                ],
       plugins:[
        [ "react-remove-properties", {"properties": ["data-testid", "data-foo" ,"data-test-id"]}],
        ["babel-plugin-styled-components"],
        ["babel-plugin-macros"]
       ]
      }),
      external(),
      commonjs(),
      resolve(),
      terser(),
      json(),
      nodePolyfills(),
      image({
        limit: 100000,
      }),
      // svg()
      // copy({
      //   targets: [
      //     { src: ['static/fontello/**'], dest: 'dist/public/icons' },
      //   ]
      // })

      font({
        "svg":"./src/static/fontello/font/fontello.svg",
        "css":{
          "include":["./src/static/css/fontello.css"]
        },
        whiteList:["icon-left"]
      })
    ],
    external: [
        'react',
        'react-dom',
      ],
  }
];
