JohnPremKumar / vite-plugin-favicons-inject

A Vite plugin for creating and injecting favicons during the application build!
MIT License
10 stars 3 forks source link

Error when using multiple entry points. #7

Open michaelmano opened 1 year ago

michaelmano commented 1 year ago

When you are using multiple input entry points you get no response so it triggers the foreach error

https://github.com/JohnPremKumar/vite-plugin-favicons-inject/blob/main/src/index.js#L61-L62


export default defineConfig(({ mode }) => {
  const env = loadEnv(mode, process.cwd(), '');
  let faviconPlugin = () => null;
  if (env.NODE_ENV === 'production') {
    faviconPlugin = vitePluginFaviconsInject('./src/favicon.svg');
  }
  return {
    test: vitestConfig.test,
    resolve: {
      alias: {
        '@': path.resolve(__dirname, './src'),
      },
    },
    define: {
      __APP_ENV__: env.APP_ENV,
    },
    root: './',
    base: './',
    build: {
      sourcemap: true,
      outDir: './dist',
      assetsDir: 'assets',
      rollupOptions: {
        input: {
          main: path.resolve(__dirname, './index.html'),
          fonts: path.resolve(__dirname, './src/fonts.ts'),
        },
        output: {
          entryFileNames: 'assets/[name].js',
          chunkFileNames: 'assets/[name].js',
          assetFileNames: 'assets/[name].[ext]',
        },
      },
    },
    plugins: [
      vue(),
      faviconPlugin(),
      createHtmlPlugin({
        minify: false, // true,
        inject: {
          data: {
            title: env.VITE_APPLICATION_TITLE,
          },
        },
      }),
    ],
  };
});

Is there any way to disable this plugin for my other separate entry points.

JohnPremKumar commented 1 year ago

As suggested, I have added the parameter to fail without errors on such above mentioned cases. You can refer the documentation for the same from here.

I am planning to add support for multiple entry points in the future version. So keeping this issue open for the meantime