Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/htdangkhoa/express-react-boilerplate

(Deprecated) πŸš€πŸš€πŸš€ This is a tool that helps programmers create Express & React projects easily base on react-cool-starter.
https://github.com/htdangkhoa/express-react-boilerplate

axios babel boilerplate code-splitting es6 eslint express flowtype jest mongodb npm-package prettier react react-router redux storybook template unit-testing universal webpack

Last synced: about 2 months ago
JSON representation

(Deprecated) πŸš€πŸš€πŸš€ This is a tool that helps programmers create Express & React projects easily base on react-cool-starter.

Awesome Lists containing this project

README

        

erb

πŸ”₯ πŸ”₯ πŸ”₯ Express react boilerplate πŸ”₯ πŸ”₯ πŸ”₯



dependency status


devDependency status


ESLint: airbnb-base


code style: prettier


github actions status



CodeFactor


MIT licensed



NPM

## Features

- Server side [(Express)](https://expressjs.com).
- NoSQL database [(MongoDB)](mongodb.com).
- Client side [(React)](https://reactjs.org).
- Universal routing [(react-router)](https://github.com/ReactTraining/react-router).
- State management [(Redux)](https://redux.js.org).
- Redux debugging tools [(redux-devtools)](https://github.com/reduxjs/redux-devtools).
- Tweak React components in real time [(react-hot-loader)](https://github.com/gaearon/react-hot-loader).
- SEO [(react-helmet)](https://github.com/nfl/react-helmet).
- The recommended Code Splitting library for React [(loadable-components)](https://github.com/gregberge/loadable-components).
- Progressive web app [(offline-plugin)](https://github.com/NekR/offline-plugin).
- Promise based HTTP client for the browser and NodeJS [(axios)](https://github.com/axios/axios).
- Internationalization [(i18next)](https://www.i18next.com/) & [(react-i18next)](https://github.com/i18next/react-i18next).
- A tool for transforming CSS with JavaScript [(PostCSS)](https://postcss.org/).
- PostCSS plugin to parse CSS and add vendor prefixes to CSS rules using values from Can I Use. It is recommended by Google and used in Twitter and Alibaba [(autoprefixer)](https://github.com/postcss/autoprefixer).
- Compiles CSS Modules in runtime [(css-modules-require-hook)](https://github.com/css-modules/css-modules-require-hook).
- Allows files required by node that match a given set of extensions to be returned as either a data URI, or a custom filename [(asset-require-hook)](https://github.com/aribouius/asset-require-hook).
- Developing UI components [(Storybook)](https://storybook.js.org/).
- Light & Dark theme.
- Data fetching from server-side.
- Compressing images with imagemin [(imagemin-webpack-plugin)](https://github.com/Klathmon/imagemin-webpack-plugin).
- Unit testing [(Jest)](https://github.com/facebook/jest).
- ES6.
- The optional chaining operator provides a way to simplify accessing values through connected objects when it's possible that a reference or function may be undefined or null [(@babel/plugin-proposal-optional-chaining)](https://babeljs.io/docs/en/babel-plugin-proposal-optional-chaining).
- Type checker for javascript [(Flow)](https://flow.org/).
- Find and fix problems in your javascript code [(ESlint)](https://eslint.org/).
- Code formatter [(Prettier)](https://prettier.io/).
- Automate your workflow from idea to production [(Github Actions)](https://github.com/features/actions).
- VSCode debugging.

## Requirements

- [Node](https://nodejs.org/en/) >= 10.13.0

## Structure

```
.
β”œβ”€β”€ public # Express server static path
β”‚ β”œβ”€β”€ assets # All favicon resources
β”‚ β”œβ”€β”€ locales # All of i18n resources
β”‚ └── robots.txt # A robots.txt file tells search engine crawlers which pages or files the crawler can or can't request from your site.
β”œβ”€β”€ src # App source code
β”‚ β”œβ”€β”€ api # All of restful API
β”‚ β”œβ”€β”€ client # Client scope
β”‚ β”‚ β”œβ”€β”€ app # App root component
β”‚ β”‚ β”œβ”€β”€ assets # Assets (e.g. images, fonts etc.)
β”‚ β”‚ β”œβ”€β”€ components # Reusable components
β”‚ β”‚ β”œβ”€β”€ pages # Page components
β”‚ β”‚ β”œβ”€β”€ stories # UI components with Storybook
β”‚ β”‚ β”œβ”€β”€ themes # App-wide style
β”‚ β”‚ β”œβ”€β”€ vendor # 3rd libraries for client
β”‚ β”‚ └── index.js # App bootstrap and rendering (webpack entry)
β”‚ β”œβ”€β”€ middlewares # All of express middleware
β”‚ β”œβ”€β”€ model # Data transfer object
β”‚ β”œβ”€β”€ mongo # MongoDB configuration
β”‚ β”œβ”€β”€ secure # All of security (e.g passport configuration, jsonwebtoken etc.)
β”‚ β”œβ”€β”€ store # Store configuration for both client and server side
β”‚ β”œβ”€β”€ tools # Project related configurations
β”‚ β”‚ β”œβ”€β”€ jest # Jest configurations
β”‚ β”‚ β”œβ”€β”€ webpack # Webpack configurations
β”‚ β”‚ β”œβ”€β”€ hooks.js # Assets require hooks
β”‚ β”‚ └── postcss.config.js # PostCSS configuration
β”‚ β”œβ”€β”€ types # All of type for flow
β”‚ β”œβ”€β”€ utils # App-wide utils
β”‚ β”œβ”€β”€ config.js # Configuration entry point loaded from .env file
β”‚ β”œβ”€β”€ i18n.js # I18next configuration
β”‚ β”œβ”€β”€ index.js # App entry point
β”‚ β”œβ”€β”€ routes.js # Routes configuration for both client and server side
β”‚ └── server.js # Express server
│── .babelrc # Babel configuration.
│── .env-cmdrc.json # All of environments configuration.
│── .eslintrc.json # Eslint configuration.
│── .flowconfig # Flow type configuration.
└── .prettierrc.json # Prettier configuration.
```

## Installation

```bash
$ yarn global add express-react-boilerplate
# or (sudo) npm install -g express-react-boilerplate
```

## Getting Started

**1. Usage:**

```bash
$ erb-gen --help

Usage: erb-gen [options]

Options:
-v, --version output the version number
-d, --dir project's directory. (default: ".")
-n, --name project's name. (default: "express-react-boilerplate")
-h, --help output usage information

Examples:
$ erb-gen
$ erb-gen --name example
```

**2. Install dependencies:**

```bash
$ cd

$ yarn
# or npm install
```

**3. Run it:**

```bash
$ yarn dev
# or npm run dev
```

## Build

```bash
$ yarn build
# or npm run build
```

---

> **NOTE**: You can change environment variables in `.env-cmdrc.json` file.

## Scripts

| Script | Description |
| ------------- | ------------------------------------------------------------------------------------- |
| dev | Start the development server. |
| dev `--serve` | Start the development server and open browser. |
| start | Start the production server. |
| build | Remove the previous bundled files and bundle it (include client & server) to `dist/`. |
| wp | Bundle client to `dist/`. |
| analyze | Visualize the contents of all your bundles. |
| storybook | Start the storybook server. |
| test | Run testing. |
| eslint | Find problems in your JavaScript code. |

## Enable/Disable offline

- In `src/tools/webpack/webpack.config.prod.js`:

```js
if (isDev) {
...
} else {
plugins = [
...,
// Comment this plugin if you want to disable offline.
new OfflinePlugin({
autoUpdate: true,
appShell: '/',
relativePaths: false,
updateStrategy: 'all',
externals: ['/'],
})
]
}
```

- At the end of `src/client/index.js`:

```js
if (!__DEV__) {
require('offline-plugin/runtime').install(); // Comment this line if you want to disable offline.
}
```

## Supported Browsers

By default, the generated project supports all modern browsers. Support for Internet Explorer 9, 10, and 11 requires polyfills. For a set of polyfills to support older browsers, use [react-app-polyfill](https://github.com/facebook/create-react-app/tree/master/packages/react-app-polyfill).

```bash
$ yarn add react-app-polyfill
# or npm install --save react-app-polyfill
```

You can import the entry point for the minimal version you intend to support to ensure that the minimum language features are present that are required to use in your project. For example, if you import the IE9 entry point, this will include IE10 and IE11 support.

### **Internet Explorer 9**

```js
// This must be the first line in /src/client/app/index.js
import 'react-app-polyfill/ie9';
import 'react-app-polyfill/stable';

// ...
```

### **Internet Explorer 11**

```js
// This must be the first line in /src/client/app/index.js
import 'react-app-polyfill/ie11';
import 'react-app-polyfill/stable';

// ...
```

## CSS variables

By default, the generated project supports all modern browsers. Support for Internet Explorer 9, 10, and 11 requires polyfills. For a set of polyfills to support older browsers, use [css-vars-ponyfill](https://github.com/jhildenbiddle/css-vars-ponyfill).

```js
// In /src/client/vendor/index.js
import cssVars 'css-vars-ponyfill';
// ... your css/scss files.
cssVars({
silent: !__DEV__,
..., // https://jhildenbiddle.github.io/css-vars-ponyfill/#/?id=options
});
```

## Type Checking For Editor

- [Visual Studio Code](https://flow.org/en/docs/editors/vscode/)
- [Atom](https://flow.org/en/docs/editors/atom/)
- [Sublime Text](https://flow.org/en/docs/editors/sublime-text/)
- [Etc.](https://flow.org/en/docs/editors/)

## Contributors

- [htdangkhoa](https://github.com/htdangkhoa)

## Special Thanks

- [(react-cool-starter) - wellyshen](https://github.com/wellyshen/react-cool-starter)

## License

MIT License

Copyright (c) 2019 Huα»³nh TrαΊ§n Đăng Khoa

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.