repack
                                
                                
                                
                                    repack copied to clipboard
                            
                            
                            
                        More control over file path and URL for remote assets
Hi team!
I'm working with remote assets, and this feature looks very promising. However, there's one feature that I'm missing: the ability to specify the URL to the file.
Describe the Feature
This feature would allow for more control over the URL of remote assets. Currently, the folder structure in the build folder generated for remote assets and the URL represents the folder structure in the repository. I would like to have more control over the URL. Therefore, I'm proposing to add an optional field to the remote object called filePath. If used, this field will control both the generated folder structure and the URL used to fetch the asset. It can be used as follows:
const filePath = getFilePath(...);
const fileHash = generateHashForFile(...);
remote: {
  enabled: isRemoteAsset,
  filePath: isRemoteAsset ? path.join(filePath, fileHash) : undefined,
  publicPath: getRemoteAssetsPublicPath(platform),
},
For example, assuming filePath is my/path/to/file and fileHash is abc123, the generated URL should be ${publicPath}/my/path/to/file/abc123/image.jpg, and this will also be the folder structure in the output folder.
Motivation
The goal is to address my use case where I need to inject a hash into the asset filename or place the asset in a folder named with the hash. I tried using the Output plugin to rename selected assets, but it did not affect the URL injected into the component pointing to the asset. In theory, I could just use publicPath for this and generate a different public path for every asset, but this would create a bit of a mess on the CDN. I created a small proof of concept to test if this is the right direction, although it is not ready to be merged. You can find more details here: https://github.com/adammruk/repack/pull/1.
Feel free to make any additional adjustments or let me know if I can solve my issue in a different way!