react-native-asset
react-native-asset copied to clipboard
preserve asset paths?
Given config:
module.exports = {
assets: ["./assets"]
};
And the following files on disk:
> tree assets/
assets/
└── www
└── test.html
I had hoped to see the "www" directory preserved in the asset path on-device. What I see instead is:
- Android: an asset path of
custom/test.html - IOS: the file is plopped right into the .app, e.g.:
/Library/Developer/CoreSimulator/Devices/28BE7070-4C6C-44C4-BBA4-2E08DDFF77F2/data/Containers/Bundle/Application/1FC5CCB6-981B-4BCA-861B-138B68B6FBE8/Foobar.app/test.html
Is this expected behavior? Is it possible to preserve my www directory on both platforms?
As for iOS, it's creates a link to the original file so no need to actually copy it, the path you have shown is just the path that the bundlers copies linked files.
As for android, there are 3 paths possible to be copied to:
- Fonts - will copy to
path.resolve(androidPath, 'app', 'src', 'main', 'assets', 'fonts')because as I remember, that's where the fonts should go when adding custom font for react native for android. - sound - will copy to
path.resolve(androidPath, 'app', 'src', 'main', 'res', 'raw')because that's what the documentation says sound files should go to. - custom - will copy to
path.resolve(androidPath, 'app', 'src', 'main', 'assets', 'custom'), I just added this because I figured it could be of use for some people.
As for 1. and 2., I believe the files needs to be copied shallowly (without folders) in order to work, as for 3., I just implemented it the same as 1. and 2. out of laziness.
It's possible to change the behaviour for custom files (and that's will be a breaking change, just mentioning it for future self if the change will be published), and anyone is welcome to PR the change, I can't do that in the near future though, school stuff.
This is a problem for me too. I've got files with the same name in different directories. Now Xcode build fails with:
Build system information
error: Multiple commands produce 'Products/Debug-iphonesimulator/MyApp.app/some.jpg':