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

usage of images key for array of images #8

Open
tripflex opened this issue Aug 18, 2023 · 5 comments
Open

usage of images key for array of images #8

tripflex opened this issue Aug 18, 2023 · 5 comments

Comments

@tripflex
Copy link
Contributor

tripflex commented Aug 18, 2023

Wondering if anybody can shed some light on how the images key would be useful as an array. Would this only be needed in the instance that you are customizing the names using assetName ?

I dug through the code and it looks like if the file already exists it will skip it, and since we can't assign a preset per image, i can't see how that would really be useful

My specific use case, I have an svg with a blue background i want to use for icon images, but not for favicon, so was trying to figure out how to generate the favicon separately.

For now I just created my own preset and removed the favicon but would be nice if there was a way to do this automatically.

@userquin
Copy link
Member

since preset is global (will be applied to all images), you can create a new config file with a custom preset for it, then add a new script running the cli with -r <custom-config-path>

@tripflex
Copy link
Contributor Author

tripflex commented Aug 31, 2023

since preset is global (will be applied to all images), you can create a new config file with a custom preset for it, then add a new script running the cli with -r <custom-config-path>

So I solved the favicon, but won't the images array just overwrite each image as it's processed. For example, you have two images in the array, only the second one will exist as generated since it just overwrites the first.

I think it would maybe make sense if the original filename was passed to https://github.com/vite-pwa/assets-generator/blob/main/src/utils.ts#L39C27-L39C27

@userquin
Copy link
Member

You have 2 config files, last one with custom preset and run from command line with that custom file

@tripflex
Copy link
Contributor Author

I'm a bit confused by response, say I have this:

export default defineConfig({
  preset: minimalPreset,
  images: ['public/one.svg', 'public/two.svg'],
});

When I run this, it will generate everything using public/one.svg but then it does public/two.svg which overwrites everything it just did for public/one.svg

@userquin
Copy link
Member

userquin commented Aug 31, 2023

If the favicon is generated with two.svg image, split your config file in 2 config files, the preset is global and cannot be shared between images.

Keep the current configuration removIng two.svg image from it and create a new config file including only two.svg image. Update both config files to generate the pwa icons only in the current and favicons only in the new one.

Add a new script to also run a new asset generation providing the new config file.

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