capacitor-assets
capacitor-assets copied to clipboard
How to only copy the images over and not regenerate?
The generation of the splash screens for our app produces images cropped in the wrong places - in fact it is not possible to automate this.
We went through updating each by hand.
Is it possible to use copyToNativeProject without trigger the regeneration?
I cobbled this ts script together but no joy:
import { copyToNativeProject } from 'cordova-res/dist/native';
import { Platform } from 'cordova-res/dist/platform';
import { DEFAULT_RESOURCES_DIRECTORY } from 'cordova-res/dist/cli';
copyToNativeProject(
Platform.ANDROID,
DEFAULT_RESOURCES_DIRECTORY,
{
directory: 'android'
},
true,
true,
null,
null
).catch(console.error);
Are you using this in Cordova or Capacitor?
Are you using this in Cordova or Capacitor?
Capacitor
Curious what the use case is if you're using Capacitor? Are you doing a whitelabel build where you're constantly replacing out the images? If so there might be some overlap between this and the new https://github.com/ionic-team/capacitor-configure we've been working on
https://capacitorjs.com/docs/guides/splash-screens-and-icons
Just following the docs essentially does not work - our icon is stretched too much on some screens, the logo falls off the edge.
To fix this we manually created the correct image for each screen - but importing them 1 by 1 into the proper place was a pain.
So to be able to just use part of this lib - to be able to auto copy and name the images from the resources folder: this is the use case.
Or, maybe there is a trick i am missing with the image generation?
Okay thanks, the context is helpful. Will look into this but not likely to get anything changed here for the 1.0.0
I took another look at this and copyToNativeProject
doesn't do any regeneration. It merely copies over the files already generated in your resources
folder. Are you seeing some other behavior?
@mlynch I think what @j-d-carmichael means is that we need a way to use the command without it actually generating the images and just have the ability to copy the assets over to the native project. I was looking for the same command ie something like cordova-res android --copy-only
which would just copy the files over without regenerating the images.
@mlynch I think what @j-d-carmichael means is that we need a way to use the command without it actually generating the images and just have the ability to copy the assets over to the native project
yup.. it is not imo possible to autogenerate images with guaranteed accuracy based on designers requirements and there is, so far for us, always a need to go in and manually tweak them.
Massive thumbs up for from me for the --copy-only flag
Ya, I was hoping to use copyToNativeProject, but I use splashicon-generator (https://www.npmjs.com/package/splashicon-generator) to generate my resources just because it allows me to configure what stuff gets generated. I'm not dependent on cordova-res if a new size is required. However, using copyToNativeProject looks like it has everything hardcoded, instead of just generically copying stuff over. So I guess I'm gonna have to do this by hand, since my set of icon names (and number of them) don't match what cordova-res is expecting.
@mlynch I found this open issue and ran into this myself as well. Right now indeed we have a whitelabel project. We solve a lot of issues by just symlinkink everything into place. But all the files and necessary items are made once.
We get a new customer. Make a new branch, edit everything that needs to be editten, run a script to "save the current variables" to a folder (think of logos, names, capacitorconfigs, ...) when I swap a customer for build, we now use the cordova-res ios/android --copy --skip-config. which would always regenerate images. In our case we copy the generated resources also over to the customer folder, so I think supplying that folder should just copy it over. (I know it is still marked as enhancement). Just to provide some isight and usecase. Ill swap over to capacitor assets as soon as we are out of rough waters, I am used to the "errors" of this beast (cordova-res).
I think I'd like to address this in https://github.com/ionic-team/trapeze instead. Follow https://github.com/ionic-team/trapeze/issues/104