Skip to content

Commit

Permalink
Adds SSR/Server for Api calls
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham-chawla committed Aug 3, 2019
0 parents commit da96976
Show file tree
Hide file tree
Showing 25 changed files with 8,852 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-env", "@babel/preset-react"]
}
23 changes: 23 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"singleQuote": true,
"printWidth": 180,
"tabWidth": 4,
"trailingComma": "all"
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Shubham Chawla

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.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
A simple server-side rendered React App.

## Available Scripts

In the project directory, you can run:

### `yarn install`
To install the dependencies

### `yarn start`

Runs the app in the development mode.<br>
Open [http://localhost:8080](http://localhost:8080) to view it in the browser.

The page will reload if you make edits.<br>
You will also see any lint errors in the console.

### `yarn build`

To make client side build in `dist/client.js` folder.<br>

### `yarn deploy`

To make server side build in `dist/server.js` folder.<br>
It correctly bundles React in production mode and optimizes the build for the best performance.<br>
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
50 changes: 50 additions & 0 deletions config/development.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

module.exports = {
entry: path.resolve(__dirname, '..', 'src/index.js'),
output: {
path: path.resolve(__dirname, '..', 'dist'),
filename: 'client.js',
},
devServer: {
contentBase: './dist',
},
resolve: {
extensions: ['.js'],
alias: {
components: path.resolve(__dirname, '..', 'src/components'),
},
},
module: {
rules: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.(scss|css)$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
},
{
test: /\.(ttf|eot|otf|svg|png)$/,
loader: 'file-loader',
},
{
test: /\.(woff|woff2)$/,
loader: 'url-loader',
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(__dirname, '..', 'index.html'),
}),
new MiniCssExtractPlugin({
filename: 'my-css-build.css',
chunkFilename: 'chunk-css-build.css',
}),
],
};
47 changes: 47 additions & 0 deletions config/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const path = require('path');
const nodeExternals = require('webpack-node-externals');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');

module.exports = {
entry: path.resolve(__dirname, '..', 'server/index.js'),
output: {
path: path.resolve(__dirname, '..', 'dist'),
publicPath: '/dist/',
filename: 'server.js',
},
target: 'node',
externals: [nodeExternals()],
resolve: {
extensions: ['.js'],
alias: {
components: path.resolve(__dirname, '..', 'src/components'),
},
},
module: {
rules: [
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
},
{
test: /\.(scss|css)$/,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
},
{
test: /\.(ttf|eot|otf|svg|png)$/,
loader: 'file-loader',
},
{
test: /\.(woff|woff2)$/,
loader: 'url-loader',
},
],
},
plugins: [
new MiniCssExtractPlugin({
filename: 'my-css-build.css',
chunkFilename: 'chunk-css-build.css',
}),
],
};
Binary file added dist/674f50d287a8c48dc19ba404d20fe713.eot
Binary file not shown.
Loading

0 comments on commit da96976

Please sign in to comment.