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: ['src/static/fontello/*'], dest: 'dist/static' },
        ]
      })

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

      // svgicons({
      //   // folder with svg-icons
      //   inputFolder: './src/static/fontello/font',  // it is default value
   
      //   // path for the sprite file
      //   output: 'dist/bundle.svg', // it is default value
      // })
    ],
    external: [
        'react',
        'react-dom',
      ],
  }
];
