KeYang89 / react-webpack-sb-boilerplate

Boilerplate with ReactJS and Webpack for S & B

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

React Webpack Boilerplate

Simple and optimized React boilerplate. It includes:

  • React 16.2.0
  • ECMAScript 6 and JSX support
  • React Router v4
  • (Optional) Component testing using Enzyme and Jest
  • Code Coverage
  • Webpack (v.3.11.0) and Webpack Dev Server (v.2.9.5) with Scope Hoisting enabled
  • Hot Module Replacement using react-hot-loader
  • ES6 linting with continuous linting on file change
  • SASS support (See Preinstallation setting below)
  • Separate CSS stylesheets generation
  • Automatic HTML generation
  • Production Config
  • Custom Babel Preset with Decorators, Class Properties, Rest/Spread operator support
  • Export Separate Vendor Files
  • Redux (We decided not use Redux)

Preinstallation setting

  1. (Optional) To use sass directly, you can install Ruby on your machine (see 4)
  1. (Optional) You can also install sass using node: npm install -g sass
  2. (Optional) Command to convert sass to scss if you have Ruby gem installed sass-convert -R your_sass_dir --from sass --to scss
  3. How to solve potential SSL issue when install Ruby:
  • In command line, run: gem sources -r https://rubygems.org/ gem sources -a http://rubygems.org/

Starting the dev server

Make sure you have the latest Stable or LTS version of Node.js installed.

  1. Download or git clone this repository
  2. Run npm install or yarn install
  3. Start the dev server using npm start
  4. Open http://localhost:8080

Available Commands

  • npm start - start the dev server
  • npm clean - delete the dist folder
  • npm cache clean - delete cache
  • npm run production - create a production ready build in dist folder
  • npm run lint - execute an eslint check
  • npm test - run all tests
  • npm run test:watch - run all tests in watch mode
  • npm run coverage - generate code coverage report in the coverage folder

Vendor Exporting

You can export specific vendors in separate files and load them. All vendors should be included in app/vendors and will be exported in a vendors folder under dist. The main idea is to serve independent JavaScript and CSS libraries, though currently all file formats are supported.

! Don't forget to add the vendors in app/index.html and build/index.html.

Code Coverage

The project is using the Jest Code Coverage tool. The reports are generated by running npm run coverage. All configurations are located in package.json, inside the jest object.

The coverage report consists of an HTML reporter, which can be viewed in the browser and some helper coverage files like the coverage json and xml file.

Production code

Run npm run production. The production-ready code will be located under dist folder.

Licence

MIT.

About

Boilerplate with ReactJS and Webpack for S & B


Languages

Language:CSS 98.0%Language:JavaScript 1.9%Language:HTML 0.1%