Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
arpitgo4 committed Oct 18, 2017
0 parents commit 727d5b4
Show file tree
Hide file tree
Showing 21 changed files with 9,234 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": ["es2015", "stage-0", "react"],
"plugins": ["transform-object-rest-spread", "transform-decorators-legacy"]
}
21 changes: 21 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"ecmaFeatures": {
"jsx": true,
"modules": true
},
"env": {
"browser": true,
"node": true
},
"parser": "babel-eslint",
"rules": {
"quotes": [2, "single"],
"strict": [2, "never"],
"react/jsx-uses-react": 2,
"react/jsx-uses-vars": 2,
"react/react-in-jsx-scope": 2
},
"plugins": [
"react"
]
}
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## libarary and third party dependencies
node_modules/

## build
dist/

## debug logs
npm-debug*
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: node_js
node_js:
- "iojs"
- "7"
env:
- NODE_ENV=production
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: npm start
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@

# React-Redux-Scaffold [![Build Status](https://travis-ci.org/arpitgo4/React-Redux-Scaffold.svg?branch=master)](https://travis-ci.org/arpitgo4/React-Redux-Scaffold)
Client side scaffold with React-Redux on the frontend and Express server to serve built files in the production mode. Scaffold supports production and development modes, with **Best Developer Experience** ( DX ) by Hot-Loading for the client side application. There will be no need to restart during development, hence making the experience smooth and decrease the delivery time.

## Scaffold Structure

```
.
├── src # Frontend source files
| ├── components # React component's source
| ├── config # Redux store's configuration
| ├── layouts # React layout component's source
| | └── App.Router.js # React Router
| ├── reducers # Redux reducer's source
| ├── index.html # Root HTML template
| ├── index.js # Frontend source entry point
| └── style.scss # Global Sass stylesheet
├── .babelrc # Babel configuration ( ES6, React, JSX )
├── .eslintrc # ESLint configuration
├── .travis.yml # Travis CI configuration file
├── devServer.js # Hot loading server source ( development mode )
├── dist # Compiled files
├── .gitignore # Ignored files from git commit
├── server.js # Express server to serve index.html and other assets
├── LICENSE # License to use the project
├── package.json # Frontend and backend dependencies
├── postcss.config.js # PostCSS configuration
├── Procfile # Heroku procfile, for deployment
├── README.md # This file
├── webpack.config.js # Webpack configuration for 'production'
└── webpack.dev.config.js # Webpack configuration for 'development'
```

## Quick Start
### Just to check everything is working
```
# Install the dependencies
npm install
# Build the client
npm run build:production
# Start the project ( it will build the client, before starting the server )
npm start
# Open web browser at http://localhost:8080
# You will see a sample Single Page Application
```

## Development
### Scaffold provides two npm scripts, execute both in seperate terminals
```
# Start client in development mode with hot code loading,
npm run start:development
```

Hit frontend dev server to load application in the browser, enjoy developing :)

Refer to the [react-hot-boilerplate](https://github.com/gaearon/react-hot-boilerplate) for further description.
## Production
### Scaffold provides two production scripts
```
# Build the client for production deployment
npm run build:production
# Build the client for production deployment and start the backend server with 'forever' package
npm start
```
Backend server will start at http://localhost:8080 or the value provided in PORT environment variable, inside **forever** process and bundled frontend client will be served from the `dist` directory.

## Known Limitations
* Hot Reloading of the Routes ( Browser refresh is needed! ).

## Feedback
In case of any query or feedback, please feel free to connect via
* [email protected] (Arpit Goyal)

Or, open an issue at github.
35 changes: 35 additions & 0 deletions devServer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const path = require('path');
const webpack = require('webpack');
const express = require('express');
const config = require('./webpack.dev.config');

const app = express();
const compiler = webpack(config);

const devConfig = config.devServer;

// middleware to serve gzipped js file.
app.get('*.js', function (req, res, next) {
req.url = req.url + '.gz';
res.set('Content-Encoding', 'gzip');
next();
});

app.use(require('webpack-dev-middleware')(compiler, {
publicPath: config.output.publicPath,
stats: { colors: true }
}));

app.use(require('webpack-hot-middleware')(compiler));

app.get('*', function(req, res) {
res.sendFile(path.join(__dirname, 'src', 'index.html'));
});

app.listen(3000, function(err) {
if (err) {
return console.error(err);
}

console.log('FrontEnd DevServer Listening at http://localhost:3000/');
});
Loading

0 comments on commit 727d5b4

Please sign in to comment.