demchenkoalex / react-native-module-template

A starter for the React Native library written in TypeScript, with linked example project and optional native code in Swift and Kotlin.
MIT License
215 stars 36 forks source link

Assets folder is not included #21

Closed jorgtz closed 2 years ago

jorgtz commented 2 years ago

I have the following folder structure:

src
   api
   assets
   components
   containers
   ...etc

All the folders and files are being included in the library except the assets and its files. I made no changes to the default package.json, it is like this:

  "files": [
    "android",
    "ios",
    "lib",
    "myproject.podspec",
    "!android/build",
    "!.DS_Store",
    "!.gradle",
    "!.idea",
    "!build",
    "!gradle",
    "!*.iml",
    "!gradlew",
    "!gradlew.bat",
    "!local.properties",
    "!project.xcworkspace",
    "!xcshareddata",
    "!xcuserdata"
  ],

How can I add the missing assets folder? Thanks!

demchenkoalex commented 2 years ago

Hey! Take a look at this project which uses the template - https://github.com/flyerhq/react-native-chat-ui. I have the similar structure (assets inside src). To include them in the lib I added a compile script

"compile": "rm -rf lib && tsc -p . && copyup src/assets/*.png lib",

which is being run on every yarn command

 "prepare": "yarn compile",

and I have copyfiles in the dev dependencies (copyup command)

and I use relative paths in my src to access assets, like that require('../../assets/icon-attachment.png') this way no matter it is a src or lib folder, it will find the resources.