Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preserve asset paths? #25

Open
jrr opened this issue Aug 13, 2019 · 2 comments
Open

preserve asset paths? #25

jrr opened this issue Aug 13, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@jrr
Copy link

jrr commented Aug 13, 2019

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?

@unimonkiez
Copy link
Owner

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:

  1. 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.
  2. sound - will copy to path.resolve(androidPath, 'app', 'src', 'main', 'res', 'raw') because that's what the documentation says sound files should go to.
  3. 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.

@unimonkiez unimonkiez added the enhancement New feature or request label Aug 14, 2019
@jorisw
Copy link

jorisw commented Aug 24, 2019

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':

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants