RaymondMik / react-boilerplate

My Webpack boilerplate for React.js projects with TypeScript and Redux

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Webpack React boilerplate with TypeScript and Redux

A basic boilerplate for React projects using TypeScript and Redux which is easy to use, extend and customize.

What you will find here

Basically all you need to startup a React project with TypeScript and Redux, including Webpack configuration files and Dev Server, Redux store, actions, reducers and a React component with a simple example application.

Webpack Setup

This boilerplate comes with two Webpack setups: development - defined in webpack.dev.config.js and build defined in webpack.build.config.js.

Get Started

Install the app

npm install

Development

Run npm run start-dev to start the development environment. Webpack will bundle JavaScript and Sass (or CSS) files into a bundle.js, which will be added to the index.html file generated using ./src/index.html as a template. Webpack Dev Server will serve the application on http://localhost:3000/ using BrowserSync.

Build

Run npm run build to build the production code. Webpack will compile, uglify and bundle JavaScript files into bundle.js and will compile and minify Sass (or CSS) files into style.css. The production build will be created in the "./dist" directory.

Hot module replacement

This project has hot module replacement enabled in development on the Redux store and the React UI as well. That means that changes in the code of reducers or React components won't cause a page reload therefore retaining the current state of the application.

Major tools and libraries you will find here

Configuration files

Each tool has is own configuration file located in the root folder:

  • Babel: .babelrc
  • ES Lint: .eslintrc.json
  • Git: .gitignore
  • Jest: jest.config.json
  • PostCSS: postcss.config.json
  • Webpack: webpack.config.js (accessing different configuration files according to the selected environment)

Sass files

In the ./src/styles folder you will find Sass partials, mixins and variables I used for this example project. You can easily switch to scss syntax as this boilerplate also support scss files.

File loader

I used Webpack File Loader in order to include external resources such as images and fonts very easily.

Fork it!

I plan to extend this boilerplate by creating different branches for specific functionalities such as routing, sagas, etc., but still keeping it as basic as possible, so other developers can easily customize it according to their needs.

About

My Webpack boilerplate for React.js projects with TypeScript and Redux


Languages

Language:JavaScript 38.2%Language:TypeScript 36.3%Language:Sass 19.7%Language:HTML 5.8%