0

I have built a small React app using the boilerplate which can be found at

https://github.com/vasanthk/react-es6-webpack-boilerplate

I have it running on my localhost no problem. However, I am unsure as to how to configure it to run live.

For example, the server js file looks like this

/* eslint-disable no-var, strict */
var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var config = require('./webpack.config');

new WebpackDevServer(webpack(config), {
  publicPath: config.output.publicPath,
  hot: true,
  historyApiFallback: true
}).listen(5000, 'localhost', function (err) {
    if (err) {
      console.log(err);
    }
    console.log('Listening at localhost:5000');
  });

If I want the index page to be at www.mydomain.com/react/ do I put this in place of localhost? Running npm install on the server also seems to install less modules then on my local machine.

Bascially I am completely new to React and Webpack and unsure as to what steps need to be taken to get it up and running in production.

I know many things can go wrong so not looking for an exact answer but some guidance would be great.

1 Answer 1

1

To use your application in production, you should build bundle js using these command:

npm run build

These command, in your boilerplate produce the following command, which build your js file for production mode:

BABEL_ENV=production ./node_modules/.bin/webpack --config webpack.config.production.js
Sign up to request clarification or add additional context in comments.

2 Comments

So I run 'npm run build', place the folder on my server, cd into it, run npm install then npm start?
@user2085143, this boilerplate is used only for developing and has nothing familiar with real production server. It can only build js for using in production. To use app in production, you should create your own server file, using library like express, which will be returning index.html from boilerplate on / route. So, in server you should have the following architecture - server.js, index.html and static/bundle.js file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.