const path = require('path');
const { build } = require('vite');
const { createSvgIconsPlugin } = require('vite-plugin-svg-icons');

(async () => {
  await build({
    configFile: false,
    publicDir: false,
    plugins: [
      createSvgIconsPlugin({
        iconDirs: [
          path.resolve(process.cwd(), 'src/assets/ICP'),
          path.resolve(process.cwd(), 'src/assets/plm'),
        ],
        symbolId: 'icon-[dir]-[name]',
        customDomId: '__svg__icons__icp__dom__',
      }),
    ],
    build: {
      rollupOptions: {
        input: {
          'svg-icons': path.resolve(process.cwd(), 'build/svg-icons/svg-icons-register.js'),
        },
        output: {
          entryFileNames: 'index.js',
        },
      },
      outDir: path.resolve(process.cwd(), 'src/assets/svg-icons/'),
    },
  });
})();
