Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Foreach Error, running in Astro #5

Open
silveltman opened this issue Nov 5, 2022 · 2 comments
Open

Foreach Error, running in Astro #5

silveltman opened this issue Nov 5, 2022 · 2 comments

Comments

@silveltman
Copy link

silveltman commented Nov 5, 2022

I'm trying to get it to work is Astro, but get the following error:

 error   Cannot read properties of undefined (reading 'forEach')
  File:
    C
  Stacktrace:
TypeError: Cannot read properties of undefined (reading 'forEach')
    at Object.closeBundle (C:\Users\silve\Documents\web-dev\astro\astro-starter\node_modules\vite-plugin-favicons-inject\dist\cjs\index.js:70:13)
    at file:///C:/Users/silve/Documents/web-dev/astro/astro-starter/node_modules/rollup/dist/es/shared/rollup.js:22748:40
    at async Promise.all (index 0)
    at async PluginDriver.hookParallel (file:///C:/Users/silve/Documents/web-dev/astro/astro-starter/node_modules/rollup/dist/es/shared/rollup.js:22676:9)
    at async Object.close (file:///C:/Users/silve/Documents/web-dev/astro/astro-starter/node_modules/rollup/dist/es/shared/rollup.js:23750:13)
    at async Promise.all (index 0)
    at async Module.build (file:///C:/Users/silve/Documents/web-dev/astro/astro-starter/node_modules/vite/dist/node/chunks/dep-c842e491.js:46421:13)
    at async ssrBuild (file:///C:/Users/silve/Documents/web-dev/astro/astro-starter/node_modules/astro/dist/core/build/static-build.js:134:10)
    at async staticBuild (file:///C:/Users/silve/Documents/web-dev/astro/astro-starter/node_modules/astro/dist/core/build/static-build.js:54:3)
    at async AstroBuilder.build (file:///C:/Users/silve/Documents/web-dev/astro/astro-starter/node_modules/astro/dist/core/build/index.js:87:5)

error Command failed with exit code 1.

astro.config.mjs

// https://astro.build/config
import { defineConfig } from 'astro/config';

// Vite plugins
import vitePluginFaviconsInject from 'vite-plugin-favicons-inject';

export default defineConfig({

  vite: {
    // Example: Add custom vite plugins directly to your Astro project
    plugins: [
      vitePluginFaviconsInject('./src/assets/logo-icon.svg'),
    ],
  }
});

I only get the error when running astro build > astro preview.
When running astro dev it doesn't do anything, no error but also no generation/injection.

probably similar to #2

@JohnPremKumar
Copy link
Owner

Hi,

This plugin tested on vite based projects and seems to be working fine.

The problem with astro based projects may be the lack of full support to the vite configurations and hooks. This specific issue might have occurred due to the fact that astro did not call the transformIndexHtml hook which is a required stage for creating and injecting the favicons.

Without the complete support for vite configurations and hooks. I don't think it's possible to make this plugin work on astro based projects at the moment.

@silveltman
Copy link
Author

That's too bad..

Thanks for the clear explanation though!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants