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

Problem bundling with assets on android if located in package #68

Open
johkade opened this issue Oct 8, 2022 · 1 comment
Open

Problem bundling with assets on android if located in package #68

johkade opened this issue Oct 8, 2022 · 1 comment

Comments

@johkade
Copy link

johkade commented Oct 8, 2022

Topic and scope of discussion

When placing assets (e.g. PNGs) in a package folder, they don't seem to be bundled correctly on android and are not displayed. iOS and web work flawlessly.

Motivation

If an asset belongs to a feature, I would like to co-locate it with that feature. And not have to place it in both of the apps as a duplicate, if possible.

Additional context

Even though the app.json specifies **/* as a path to bundle assets, android doesn't show anything where the image should be. iOS and web work without any troubles after a rebuild. Throwing the assets into expo/assets works on all three platforms.

It would be great to hear, what the preferred approach for shared assets is with this monorepo-example 🤩

Thanks a lot for any input in advance!

@byCedric
Copy link
Owner

This is a good question, I'd have to dig a bit deeper into what the best way would be. I'll add an internal task to document this on docs.expo.dev too.

For now, I think it's good to mention a slight behavior change in the classic builds and EAS build (or building it yourself).

  1. assetBundlePatterns was mostly intended to auto-bundle certain assets, even if they aren't imported (dynamically importing - require(\./asset/${dynamic}.png`)` - assets is also not detectable, hence this was created).
  2. With EAS build or building it yourself, any asset file imported through JS (e.g. import './assets/my-image.png') is bundled automatically.

That being said, you should be able to add assets in a workspace package and import it. E.g. with:

  • If you import the asset within the workspace package, a relative path should work (import './assets/my-image.png')
  • If you import the asset from another workspace, something like import 'my-pkg/assets/my-image.png' should work too.

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

No branches or pull requests

2 participants