React Slingshot is a comprehensive starter kit for rapid application development using React.
- One command to get started - Type
npm startto start development in your default browser.
- Rapid feedback - Each time you hit save, changes hot reload and linting and automated tests run.
- One command line to check - All feedback is displayed on a single command line.
- Working example app - The included example app shows how this all works together.
- Automated production build - Type
npm run buildto do all this:
- Initial Machine Setup. First time running the starter kit? Then complete the Initial Machine Setup.
- Clone the project.
git clone https://github.com/coryhouse/react-slingshot.git.
- Run the setup script.
npm run setup
- Run the example app.
npm start -sThis will run the automated build process, start up a webserver, and open the application in your default browser. When doing development with this kit, this command will continue watching all your files. Every time you hit save the code is rebuilt, linting runs, and tests run automatically. Note: The -s flag is optional. It enables silent mode which suppresses unnecessary messages during the build.
- Review the example app. This starter kit includes a working example app that calculates fuel savings. Note how all source code is placed under /src. Tests are placed alongside the file under test. The final built app is placed under /dist. These are the files you run in production.
- Delete the example app files. Once you're comfortable with how the example app works, you can delete those files and begin creating your own app.
- Having issues? See "Having Issues?" below.
Initial Machine Setup
- Install Node 4.0.0 or greater - (5.0 or greater is recommended for optimal build performance). Need to run multiple versions of Node? Use nvm.
- Install Git.
- Disable safe write in your editor to assure hot reloading works properly.
- On a Mac? You're all set. If you're on Linux or Windows, complete the steps for your OS below.
- Run this to increase the limit on the number of files Linux will watch. Here's why.
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
- Install Python 2.7. Some node modules may rely on node-gyp, which requires Python on Windows.
- Install C++ Compiler. Browser-sync requires a C++ compiler on Windows. Visual Studio Express comes bundled with a free C++ compiler. Or, if you already have Visual Studio installed: Open Visual Studio and go to File -> New -> Project -> Visual C++ -> Install Visual C++ Tools for Windows Desktop. The C++ compiler is used to compile browser-sync (and perhaps other Node modules).
Having Issues? Try these things first.
- Make sure you ran all steps in Get started including the initial machine setup.
npm install- If you forget to do this, you'll see this:
babel-node: command not found.
- Install the latest version of Node. Or install Node 5.12.0 if you're having issues on Windows. Node 6 has issues on some Windows machines.
- Make sure files with names that begin with a dot (.babelrc, .editorconfig, .eslintrc) are copied to the project directory root. This is easy to overlook is you copy this repository manually.
- Don't run the project from a symbolic link. It may cause issues with file watches.
- Delete any .eslintrc that you're storing in your user directory. Also, disable any ESLint plugin / custom rules that you've enabled within your editor. These will conflict with the ESLint rules defined in this project.
Slingshot offers a rich development experience using the following technologies:
|React||Fast, composable client-side components.||Pluralsight Course|
|Redux||Enforces unidirectional data flows and immutable, hot reloadable store. Supports time-travel debugging. Lean alternative to Facebook's Flux.||Pluralsight Course|
|React Router||A complete routing library for React||Pluralsight Course|
|Webpack||Bundles npm packages and our JS into a single file. Includes hot reloading via react-transform-hmr.||Quick Webpack How-to Pluralsight Course|
|Browsersync||Lightweight development HTTP server that supports synchronized testing and debugging on multiple devices.||Intro vid|
|Mocha||Automated tests with Chai for assertions and Enzyme for DOM testing without a browser using Node.||Pluralsight Course|
|Isparta||Code coverage tool for ES6 code transpiled by Babel.|
|ESLint||Lint JS. Reports syntax and style issues. Using eslint-plugin-react for additional React specific linting rules.|
|SASS||Compiled CSS styles with variables, functions, and more.||Pluralsight Course|
|PostCSS||Transform styles with JS plugins. Used to autoprefix CSS|
|Editor Config||Enforce consistent editor settings (spaces vs tabs, etc).||IDE Plugins|
|npm Scripts||Glues all this together in a handy automated build.||Pluralsight course, Why not Gulp?|
The starter kit includes a working example app that puts all of the above to use.
Check out the FAQ