import typescript from "@rollup/plugin-typescript";
import resolve from "@rollup/plugin-node-resolve";
import babel from "@rollup/plugin-babel";
import { terser } from "rollup-plugin-terser";

export default [
  // Configuración para la carpeta lib
  {
    input: {
      index: "src/lib/index.ts",
      iconBase: "src/lib/iconBase.tsx",
      iconContext: "src/lib/iconContext.tsx",
    },
    output: {
      dir: "dist/lib",
      format: "es",
      sourcemap: false,
      entryFileNames: "[name].js",
    },
    plugins: [
      resolve(),
      babel({
        extensions: [".js", ".jsx", ".ts", ".tsx"],
        babelHelpers: "bundled",
        presets: ["@babel/preset-typescript", "@babel/preset-react"],
      }),
      typescript({
        tsconfig: "./tsconfig.json",
        rootDir: "src/lib",
        outDir: "dist/lib",
        declarationDir: "dist/lib",
        declaration: true,
      }),
      terser(),
    ],
    external: ["react"],
  },
  // Configuración para los iconos generales
  {
    input: {
      fa: "src/fa/index.ts",
      fc: "src/fc/index.ts",
      rx: "src/rx/index.ts",
      tfi: "src/tfi/index.ts",
    },
    output: {
      dir: "dist",
      format: "es",
      sourcemap: false,
      entryFileNames: "[name]/index.js",
    },
    plugins: [
      resolve(),
      babel({
        extensions: [".js", ".jsx", ".ts", ".tsx"],
        babelHelpers: "bundled",
        presets: ["@babel/preset-typescript", "@babel/preset-react"],
      }),
      typescript({
        tsconfig: "./tsconfig.json",
        rootDir: "src",
        outDir: "dist",
        declarationDir: "dist",
        declaration: true,
      }),
      terser(),
    ],
    external: ["react", "../lib"],
  },
  // Configuración para los iconos hi
  {
    input: {
      solid: "src/hi/solid/index.ts",
      outline: "src/hi/outline/index.ts",
    },
    output: {
      dir: "dist/hi",
      format: "es",
      sourcemap: false,
      entryFileNames: "[name]/index.js",
    },
    plugins: [
      resolve(),
      babel({
        extensions: [".js", ".jsx", ".ts", ".tsx"],
        babelHelpers: "bundled",
        presets: ["@babel/preset-typescript", "@babel/preset-react"],
      }),
      typescript({
        tsconfig: "./tsconfig.json",
        declaration: true,
        rootDir: "src",
        outDir: "dist/hi",
        declarationDir: "dist/hi",
        include: ["src/hi/**/*", "src/lib/**/*"],
      }),
      terser(),
    ],
    external: ["react", "../../lib"],
  },
  // Configuración para el archivo principal en hi
  {
    input: "src/hi/index.ts",
    output: {
      file: "dist/hi/index.js",
      format: "es",
      sourcemap: false,
    },
    plugins: [
      resolve({
        extensions: [".js", ".jsx", ".ts", ".tsx"],
      }),
      babel({
        extensions: [".js", ".jsx", ".ts", ".tsx"],
        babelHelpers: "bundled",
        presets: ["@babel/preset-typescript", "@babel/preset-react"],
      }),
      typescript({
        tsconfig: "./tsconfig.json",
        declaration: true,
        rootDir: "src",
        outDir: "dist/hi",
        declarationDir: "dist/hi",
        include: ["src/hi/index.ts", "src/lib/**/*"],
      }),
      terser(),
    ],
    external: ["react", "../../lib", "./solid", "./outline"],
  },
  // Configuración para el archivo principal en dist/
  {
    input: "src/index.ts",
    output: {
      file: "dist/index.js",
      format: "es",
      sourcemap: false,
    },
    plugins: [
      resolve(),
      babel({
        extensions: [".js", ".jsx", ".ts", ".tsx"],
        babelHelpers: "bundled",
        presets: ["@babel/preset-typescript", "@babel/preset-react"],
      }),
      typescript({
        tsconfig: "./tsconfig.json",
        rootDir: "src",
        outDir: "dist",
        declarationDir: "dist",
        declaration: true,
      }),
      terser(),
    ],
    external: ["react"],
  },
];
