GithubHelp home page GithubHelp logo

kkoomen / react-boilerplate Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 2.0 1.33 MB

An extension of create-react-app with some extras: hot-reloading, linters, redux, redux-thunk, routing and basic structure.

JavaScript 86.23% HTML 1.37% SCSS 12.41%
create-react-app create-react-app-v2 hot-reloading redux immutablejs eslint redux-thunk react localstorage plop

react-boilerplate's Introduction

React boilerplate

An ejected version of create-react-app v2 with some extras:

  • hot reloading ๐Ÿ”ฅ
  • linters
  • redux
  • redux-thunk
  • routing
  • ImmutableJS
  • local storage (for the redux state)
  • basic structure
  • absolute imports
  • plop templates

This version also has built-in support for the following extensions:

Table of contents

  1. Branches
  2. Getting started
  3. Absolute imports
  4. Environments
  5. Linting
  6. Useful tools
    1. Chrome extensions
    2. Template generators

Branches

  • bootstrap-4

    A duplicate of the master branch, including bootstrap 4.

Getting started

  • Clone the repository
  • (optional, but recommended) Go into package.json and set the name property at the top to your new project its name. This will also set local storage keys automatically correct.
  • Run npm install
  • Run npm start

Absolute imports

This repository supports absolute paths where src is an alias to the /src directory. Absolute imports improve readability, consistency and the component can be moved easily in structure without the hassle of adjusting the import paths.

Example:

  • JSX: import Button from 'src/components/Button';
  • SCSS: background-image: url('~src/assets/images/icons/icongrid.svg');

Environments

TLDR; If you want to add a new environment (for example: staging) the only thing you have to do is the following:

  • Copy over the build script in the package.json to a build:staging script.
  • Change the REACT_APP_ENV=production to REACT_APP_ENV=staging in the build:staging script.

--

Instead of overwriting NODE_ENV we will use REACT_APP_ENV to distinguish between environments. CRA sets the NODE_ENV for us at build-time which ensures a correct build at any time. This saves us extra code to adjust in the CRA config for it to work. At the end we are aiming for a variable per environment that tells us the type of environment. If you want to distinguish between environments programmatically you want to use process.env.REACT_APP_ENV or (preferably) use import { APP_ENV } from 'src/config/constants'; which is pre-defined in this repository.

If you want a bit more info you can read it at https://facebook.github.io/create-react-app/docs/adding-custom-environment-variables.

Linting

All rules within linting are set to a warning, except for those that are definitely a no-op, such as deprecated functions, or really bad ways of handling code such as the use of eval(). Linters should suggest, not force.

If you find any rules that are left out or should be different, feel free to make a pull request.

Useful tools

Optional extensions that might be useful.

Chrome extensions

Template generators

react-boilerplate's People

Contributors

dependabot[bot] avatar kkoomen avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

yunusemre d4mn

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.