Saturday, 15 April 2017

How do I deploy my reactJS application on web server public to internet

I started following reatJS tutorial from Youtube, now I want to share my learning step by step with the LEAD developers over internet.

I have npm /node js installed on my macbook, and I after I finish work i run npm start and it gives me local host address on port 8081 , but I have apache web server running on different machine which is open to internet , so I want to deploy my reactJS app using npm / webpack to this computer running apache.

I have this package.json file setup.

{
  "name": "react-basics",
  "version": "1.0.0",
  "description": "Some Basics ReactJS",
  "main": "index.js",
  "scripts": {
    "start": "npm run build",
    "build": "webpack -d && cp src/index.html dist/index.html && webpack-dev-server --content-base src/ --inline --hot",
    "build:prod": "webpack -p && cp src/index.html dist/index.html"
  },
  "keywords": [
    "reactJS"
  ],
  "author": "Sanjeev Kumar",
  "license": "MIT",
  "dependencies": {
    "react": "^15.5.3",
    "react-dom": "^15.5.3"
  },
  "devDependencies": {
    "babel-core": "^6.24.1",
    "babel-loader": "^6.4.1",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "babel-preset-stage-2": "^6.24.1",
    "webpack": "^2.3.3",
    "webpack-dev-server": "^2.4.2"
  }
}

and webpack.config.js

var webpack = require("webpack");
var path = require("path");

var DIST_DIR = path.resolve(__dirname, "dist");
var SRC_DIR = path.resolve(__dirname, "src");

var config = {
    entry: SRC_DIR + "/app/index.js",
    output: {
        path: DIST_DIR + "/app",
        filename: "bundle.js",
        publicPath: "/app/"
    },
    module: {
        loaders: [
        {
            test: /\.js?/,
            include: SRC_DIR,
            loader: "babel-loader",
            query: {
                presets: ["react", "es2015", "stage-2"]
            }
        }

        ]
    }



};

module.exports = config;

Do I have to install npm /node.js on remote machine as well which is open to internet ? can I not just use apache web server ? if so how do I just stick to port 80 ?



via Ciasto piekarz

No comments:

Post a Comment