To use a subfolder for deploying an Expo React Native Web app, the following steps can be followed:
Create a new React Native project using the Expo CLI.
Navigate to the project directory and install the necessary dependencies.
Modify the "app.json" file to include the "expo.web.build.publicPath" property with the desired subfolder path, for example:
{
"expo": {
"web": {
"build": {
"publicPath": "/subfolder/" // set the desired subfolder path
}
}
}
}
Update the project's "package.json" file to include the "homepage" property with the same subfolder path specified in the "app.json" file, for example:
{
"name": "my-app",
"homepage": "./subfolder",
...
}
Build the app for web using the command expo build:web
.
Once the build is complete, the output can be found in the "web-build" directory. Copy the contents of this directory (excluding the "index.html" file) to the desired subfolder on the server.
Update the "index.html" file to include the correct path to the app's JavaScript bundle, which should include the subfolder path, for example:
<script src="./subfolder/static/js/bundle.js"></script>
The app should now be accessible at the specified subfolder path on the server.
Asked: 2022-07-12 11:00:00 +0000
Seen: 7 times
Last updated: Oct 13 '22