Ask Your Question
3

How can a subfolder be used for deploying an Expo React Native Web app?

asked 2022-07-12 11:00:00 +0000

lakamha gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-10-13 00:00:00 +0000

david gravatar image

To use a subfolder for deploying an Expo React Native Web app, the following steps can be followed:

  1. Create a new React Native project using the Expo CLI.

  2. Navigate to the project directory and install the necessary dependencies.

  3. 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
         }
       }
     }
    }
    
  4. 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",
     ...
    }
    
  5. Build the app for web using the command expo build:web.

  6. 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.

  7. 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>
    
  8. The app should now be accessible at the specified subfolder path on the server.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2022-07-12 11:00:00 +0000

Seen: 7 times

Last updated: Oct 13 '22