assets-generator icon indicating copy to clipboard operation
assets-generator copied to clipboard

usage of images key for array of images

Open tripflex opened this issue 1 year ago • 5 comments

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.

tripflex avatar Aug 18 '23 14:08 tripflex

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>

userquin avatar Aug 21 '23 11:08 userquin

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

tripflex avatar Aug 31 '23 20:08 tripflex

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

userquin avatar Aug 31 '23 20:08 userquin

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

tripflex avatar Aug 31 '23 21:08 tripflex

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.

userquin avatar Aug 31 '23 21:08 userquin