assets-generator
assets-generator copied to clipboard
usage of images key for array of images
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.
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>
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
You have 2 config files, last one with custom preset and run from command line with that custom file
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
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.