Reactify
  • Introduction
  • Folder Structure
  • Reactify Redux Thunk/Saga
    • Installation
    • Different Layouts
      • Adding Menu/Component In Different Layouts
    • Adding Widgets
    • Build an App from Scratch
    • Seed Project
    • Themes
    • Authentication
    • Translate The App(Multi Language Support)
    • UI Components
      • Alerts
      • App Bar
      • Avatars
      • Badges
      • Bottom Navigation
      • Buttons
      • Cards
      • Card Masonary
      • Chip
      • Dialogs
      • Divider
      • Drawers
      • Expansion Panel
      • Grid List
      • List
      • Menu
      • Pop Over & ToolTip
      • Progress
      • Snackbar
      • Selection Controls
    • Style Customization
    • Create a Docker Image
    • Instant Search With Algolia
    • Deployment
  • Reactify Laravel
    • Folder Structure
    • Installation Reactify Laravel
  • FAQ's(Frequently Asked Questions)
  • Credits
  • Changelog
  • Customer Support
Powered by GitBook
On this page
  1. Reactify Redux Thunk/Saga

Deployment

In this section you will learn about how to deploy your application on the live server. Please read the documentation carefully.

PreviousInstant Search With AlgoliaNextReactify Laravel

Last updated 6 years ago

To create a production build you need to run the command npm run build. It will create the dist folder, that contains the production build files. Now you just need to upload the dist files on to the server.

Static Server:

For environments using , the easiest way to handle this would be to install and let it handle the rest:

npm install -g serve
serve -s build

Other Solutions:

You don’t necessarily need a static server in order to run a project in production. It works just as fine integrated into an existing dynamic one.

Here’s a programmatic example using and :

server.js
const express = require('express');
const path = require('path');
const app = express();

app.use(express.static(path.join(__dirname, 'build')));

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

app.listen(9000);

Apache HTTP server:

Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]

Upload the dist files in the public folder.

Building for Relative Paths:

If you want to make your production build in different folder or sub directory. Like, if you want that the template run on the test.com/dist rather then test.com then you need to follow the steps given below:

Step 1: Open .webpack.config.js file and search for

const publicPath = '/';

and set your path as per requirement like:

const publicPath = '/dist/';

Step 2: Now go to src>App.js file and set the Router basename to dist like following code:

<Router basename={'/dist'}>
            <Switch>
               <Route path="/" component={App} />
            </Switch>
         </Router> 

Step 3: Open .htaccess file and set the roots for subdirectory: We have added the screenshot for the .htaccess file location and also the code of the file.

.htaccess
# To be inside the /Directory

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /dist/
    RewriteRule ^index\.html$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /dist/index.html [L]
</IfModule>

If you’re using , you need to create a .htaccess file in the public folder that looks like this:

Node
serve
Node
Express
Apache HTTP Server
.htaccess File