React Slingshot Deploy & Usage Guide
Prerequisites
Required Runtime & Tools
- Node.js: Version 8.0.0 or greater (LTS recommended)
- Git: For repository management
- npm: Bundled with Node.js
Operating System Specifics
macOS:
- Install file watching service to avoid CPU usage issues:
brew install watchman # or brew install fswatch
Linux:
- Increase inotify watch limit:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
Windows:
- Python 2.7: Required for node-gyp dependencies
- C++ Compiler: Visual Studio Express or Visual C++ Tools for Windows Desktop (required for browser-sync compilation)
Editor Configuration
- Disable Safe Write: Configure your editor to disable "safe write" feature to ensure hot reloading works properly (see Webpack guide)
Installation
Option 1: Use GitHub Template (Recommended)
- Click the green "Use this template" button on the repository page
- Enter your repository name and description
- Clone your new repository:
git clone https://github.com/YOUR_USERNAME/YOUR_REPO_NAME.git cd YOUR_REPO_NAME
Option 2: Clone Directly
git clone https://github.com/coryhouse/react-slingshot.git
cd react-slingshot
Run Setup
Execute the automated setup script to install dependencies and configure your project:
npm run setup
This will:
- Install npm dependencies
- Prompt for project details (name, version, author, license, description)
- Remove the original git repository (optional)
- Update
package.jsonwith your settings
Note: If you skip npm run setup, run npm install manually, then manually update package.json and remove the .git directory if desired.
Configuration
Environment Variables
- Ensure
NODE_ENVis NOT set toproductionon your development machine. If set, development dependencies won't install. - Check your current setting:
echo $NODE_ENV(Unix) orecho %NODE_ENV%(Windows) - If set to production, unset it before installing dependencies.
Project Metadata
During npm run setup, you'll configure:
- Project name
- Version (default: 0.1.0)
- Author
- License (default: MIT)
- Description
These values are written to package.json.
Source Structure
- Source code:
/src - Tests: Placed alongside files under test (e.g.,
Component.jsandComponent.test.js) - Production build:
/dist(generated, not committed)
Build & Run
Development Mode
Start the development server with hot reloading, linting, and automated testing:
npm start
For silent mode (suppresses unnecessary messages):
npm start -s
Features:
- Webpack dev server with hot module replacement
- Source maps via
cheap-module-eval-source-map - ESLint running on save
- Tests running automatically
- Redux DevTools extension support
Production Build
Generate optimized static files for deployment:
npm run build
Output:
- Bundles placed in
/distdirectory - Hashed filenames for cache busting (e.g.,
main.[contenthash].js) - Extracted CSS files with hashing
- Minified HTML, JS, and CSS
- Source maps generated
Reviewing the Example App
The starter includes a working Fuel Savings calculator app. Review the structure under /src before deleting example files to create your own app.
Deployment
Static Hosting
The /dist folder contains static files suitable for any static host:
Recommended Platforms:
- Netlify: Drag and drop
/distfolder or connect git repo with build commandnpm run buildand publish directorydist - Vercel: Configure build command as
npm run buildand output directory asdist - GitHub Pages: Push
/distcontents togh-pagesbranch - AWS S3: Upload
/distcontents to S3 bucket with static website hosting enabled - Surge:
surge dist
SPA Configuration
Since this uses React Router (connected-react-router), configure your server to serve index.html for all routes:
- Nginx:
try_files $uri /index.html; - Apache:
FallbackResource /index.html - Netlify/Vercel: Create
_redirectsfile with/* /index.html 200
Environment Checklist Before Deploy
- Run
npm run buildlocally to verify no errors - Verify
NODE_ENVis not set to production in your build environment (unless doing a production build) - Ensure
/distcontainsindex.html, hashed JS/CSS files, and assets
Troubleshooting
Installation Issues
| Issue | Solution |
|---|---|
babel-node: command not found | Run npm install or npm run setup |
| Missing dev dependencies | Ensure NODE_ENV is not set to production |
| Hidden files missing | Verify .editorconfig, .gitignore, .npmrc, .eslintrc copied to project root |
File Watching / Hot Reload Failures
| Issue | Solution |
|---|---|
| Hot reload not working | Disable "safe write" in your editor |
| macOS: High CPU usage | Install watchman via brew install watchman |
Linux: ENOSPC error | Run echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p |
| Symbolic link issues | Don't run the project from a symlinked directory |
Build Errors
| Issue | Solution |
|---|---|
| ESLint conflicts | Delete any .eslintrc in your user home directory; disable ESLint plugins in editor |
| Windows: Python/C++ errors | Install Python 2.7 and Visual Studio C++ compiler (see Prerequisites) |
| Module not found | Ensure all dotfiles (.babelrc, etc.) are present in project root |
Runtime Issues
| Issue | Solution |
|---|---|
| Redux DevTools not working | Ensure browser extension is installed; falls back to compose if unavailable |
| Router not syncing | Verify connected-react-router middleware is applied in configureStore.js |
Post-Setup Cleanup
After reviewing the example app, delete example files:
- Remove Fuel Savings components from
/src/components - Update
/src/reducers/index.jsto remove fuel savings reducer - Update
/src/index.jsto render your root component instead of example app