I have some resource files that I need to copy from /app/resources
to both /android/app/src/main/ress/raw
and /ios/<project>/resources
when I build. I assume there's a way to do this, but I'm not familiar with how react-native
/Gradle/XCode builds.
For gradle, I tried adding to /android/app/build.gradle
task copySounds(type: Copy) {
from '../../app/resources/sounds/*'
into 'src/main/res/raw/'
}
and to /android/.idea/workspace.xml
<project version="4">
// ...
<component name="GradleLocalSettings">
// ...
<option name="availableTasks">
<map>
<entry>
// ...
<value>
<list>
// ...
<ExternalTaskPojo>
<option name="linkedExternalProjectPath" value="$PROJECT_DIR$" />
<option name="name" value="copySounds" />
</ExternalTaskPojo>
// ...
</list>
</value>
</entry>
// ...
</map>
</option>
// ...
</component>
</project>
but it didn't seem to do anything. My guess is I need to add a third reference somewhere, but I can't figure out where.
This could be done in the scripts section of package. json at the root of your project. For instance, below I am running ./scripts/script-to-run-before-RN-build.sh before React Native packager is being called to perform the build.
The post-build script runs after the build has finished and copied all the necessary artifacts to the output directory. The post-build script will run even if the build fails.
This could be done in the scripts section of package.json at the root of your project.
For instance, below I am running ./scripts/script-to-run-before-RN-build.sh before React Native packager is being called to perform the build.
"scripts": {
"start": "npm run pre-packager && node node_modules/react-native/local-cli/cli.js start",
"pre-packager": "./scripts/script-to-run-before-RN-build.sh"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With