Skip to content

Instantly share code, notes, and snippets.

@kany
Last active November 6, 2019 11:07
Show Gist options
  • Save kany/678599984a75cd3cf428463427fb84fd to your computer and use it in GitHub Desktop.
Save kany/678599984a75cd3cf428463427fb84fd to your computer and use it in GitHub Desktop.
Deploy Facebooks' React VR `TourSample` to Heroku in 5 minutes or less

Deploy Facebooks' React VR TourSample to Heroku in 5 minutes or less

Step by step instructions for deploying react-vr/tree/master/Examples/TourSample to Heroku.

Demo

https://serene-retreat-76943.herokuapp.com/index.html

Shout-outs to:

  1. Facebook for their VR framework React VR.

  2. zivile777 for her example use of React VR with react-vr-paris-tour.

  3. ltfschoen for his example use of React VR with PolkadotConsensusVR.

The following steps require:

* Node.js version 6.0.0 or higher
* npm (>= v3.0.0) package manager

Condensed Steps

  1. In the terminal, from your working directory(example: ~/projects), copy/paste these commands, hit Enter:
npm install -g react-vr-cli \
&& git clone https://github.com/facebook/react-vr.git \
&& cd react-vr/Examples \
&& react-vr init TourSampleTest \
&& cd TourSampleTest \
&& rm -rf static_assets \
&& cp -r ../TourSample/static_assets static_assets \
&& cp ../TourSample/{InfoButton.js,LoadingSpinner.js,NavButton.js,Tooltip.js,index.vr.js} . \
&& sed -i '' 's/TourSample/TourSampleTest/g' index.vr.js \
&& npm run bundle \
&& cp -r ./static_assets vr/build/static_assets \
&& cp vr/index.html vr/build
  1. Modify vr/build/index.html (NOT vr/index.html)
  • Replace '<script src="./build/client.bundle?platform=vr"></script>' with '<script src="./client.bundle.js?platform=vr"></script>'
  • Replace './build/index.bundle?platform=vr&dev=false', with './index.bundle.js?platform=vr',
  • Modify document.body with the following for all static assets:
    document.body,
    {}, 
    ['./static_assets/Three-Cocktails.jpg', 
     './static_assets/Three-Cocktails.webm', 
     './static_assets/beer-cheers.jpg', 
     './static_assets/cafe.wav', 
     './static_assets/chalkboard-menu.jpg', 
     './static_assets/chester_icon.png', 
     './static_assets/circle_ramp.png', 
     './static_assets/info_icon.png',
     
     './static_assets/License.html', 
     './static_assets/menu-click.wav', 
     './static_assets/old-fashioned.jpg', 
     './static_assets/react_logo.png', 
     './static_assets/switch-flip.wav',
     './static_assets/the-chester--v112351.prefilter.jpg',
     './static_assets/the-chester--v112355.prefilter.jpg',
     './static_assets/the-chester--v112362.prefilter.jpg',
     './static_assets/the-chester--v112371.prefilter.jpg',
     './static_assets/the-chester--v112379.prefilter.jpg',
     './static_assets/the-chester--v112392.prefilter.jpg',
     './static_assets/the-chester--v112393.prefilter.jpg',
     './static_assets/the-chester--v112399.prefilter.jpg',
     './static_assets/tourOfTheChester.json',
     './static_assets/whiskey-sour.jpg'
     ]
    
  1. echo "<?php header( 'Location: /index.html' ) ; ?>" > vr/build/index.php
  2. cd vr/build
  3. heroku login
  4. git init && git add . && git commit -m "my first commit"
  5. heroku create && git push heroku master
  6. visit https://url-generated-from-previous-step.herokuapp.com

Detailed Step by Step Directions

  1. Install the React VR CLI – a command-line tool

npm install -g react-vr-cli

  1. Clone the React VR repo git clone https://github.com/facebook/react-vr.git

  2. Change working directory to Examples

cd react-vr/Examples/

  1. Initialize a new React VR project

react-vr init TourSampleTest

  1. Change working directory to new project and remove static_assets folder

cd TourSampleTest && rm -rf static_assets/

  1. Copy static_assets folder from example project

cp -r ../TourSample/static_assets static_assets

  1. Copy js files from example project

cp ../TourSample/{InfoButton.js,LoadingSpinner.js,NavButton.js,Tooltip.js,index.vr.js} .

  1. Replace TourSample with TourSampleTest

sed -i '' 's/TourSample/TourSampleTest/g' index.vr.js

  1. Build the project

npm run bundle

  1. Copy static_assets into the build

cp -r ./static_assets vr/build/static_assets

  1. Copy index.html into the build

cp vr/index.html vr/build

  1. Modify vr/build/index.html (NOT vr/index.html)
  • Replace '<script src="./build/client.bundle?platform=vr"></script>' with '<script src="./client.bundle.js?platform=vr"></script>'
  • Replace './build/index.bundle?platform=vr&dev=false', with './index.bundle.js?platform=vr',
  • Modify document.body with the following for all static assets:
    document.body,
    {}, 
    ['./static_assets/Three-Cocktails.jpg', 
     './static_assets/Three-Cocktails.webm', 
     './static_assets/beer-cheers.jpg', 
     './static_assets/cafe.wav', 
     './static_assets/chalkboard-menu.jpg', 
     './static_assets/chester_icon.png', 
     './static_assets/circle_ramp.png', 
     './static_assets/info_icon.png',
     
     './static_assets/License.html', 
     './static_assets/menu-click.wav', 
     './static_assets/old-fashioned.jpg', 
     './static_assets/react_logo.png', 
     './static_assets/switch-flip.wav',
     './static_assets/the-chester--v112351.prefilter.jpg',
     './static_assets/the-chester--v112355.prefilter.jpg',
     './static_assets/the-chester--v112362.prefilter.jpg',
     './static_assets/the-chester--v112371.prefilter.jpg',
     './static_assets/the-chester--v112379.prefilter.jpg',
     './static_assets/the-chester--v112392.prefilter.jpg',
     './static_assets/the-chester--v112393.prefilter.jpg',
     './static_assets/the-chester--v112399.prefilter.jpg',
     './static_assets/tourOfTheChester.json',
     './static_assets/whiskey-sour.jpg'
     ]
    
  1. Create index.php file to trick Heroku

echo "<?php header( 'Location: /index.html' ) ; ?>" > vr/build/index.php

  1. Change working directory to build

cd vr/build

  1. Login to Heroku

heroku login

  1. Initialize for Heroku

git init && git add . && git commit -m "my first commit"

  1. Create a new Heroku project

heroku create

  1. Deploy build to Heroku

git push heroku master

  1. visit https://url-generated-from-previous-step.herokuapp.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment