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 typescript from "@rollup/plugin-typescript";

export default [
	{
		input: "./src/index.tsx",
		output: [
			{
				file: "dist/index.js",
				format: "cjs",
				sourcemap: true
			},
			{
				file: "dist/index.es.js",
				format: "es",
				exports: "named",
				sourcemap: true
			}
		],
		plugins: [
			babel({
				exclude: "node_modules/**",
				presets: ["@babel/preset-react"]
			}),
			postcss({
				config: {
					path: "./postcss.config.js"
				},
				extensions: [".css"],
				minimize: true,
				inject: {
					insertAt: "top"
				}
			}),
			typescript({ tsconfig: "./tsconfig.json" }),
			external(),
			resolve({ extensions: [".js", ".jsx", ".ts", ".tsx"] }),
			terser(),
			commonjs(),
			json()
		]
	}
];
