Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run a react app on tomcat

I'm trying to run the following example: https://github.com/ceolter/ag-grid-react-example

(ag-grid react example)

But, instead of doing npm run I want to run it on tomcat. How to do it?

like image 232
Angad Avatar asked Oct 13 '16 20:10

Angad


2 Answers

You can easily deploy any static files on Tomcat. The project you linked does not have a script to build production version of the sample, so what you need to do is:

  1. Install webpack locally: npm install -g webpack
  2. Build demo: webpack --config webpack.config.standard.js --progress --colors --hot --inline or webpack --config webpack.config.large.js --progress --colors --hot --inline. It will create dist directory.
  3. In Tomcat webapps directory create create another directory for your demo ag-grid.
  4. Copy index.html and dist to ag-grid.
  5. Access it on http://host:port/ag-grid.
like image 182
Maciej Walkowiak Avatar answered Nov 15 '22 06:11

Maciej Walkowiak


Execute

npm run build

This will create the deployable version of your app in the build subfolder inside your project tree. All you need now is to copy the index.html with its all friends from this folder into your Tomcat directory intended to serve static files. This is the top level in the Tomcat application folder. The standard directory layout documented here.

It is also very simple build a real web application (.war) as described here. Static files just reside on the top level of the archive, you should also configure default pages in WEB-INF/web.xml inside the archive. Such app can be deployed from Tomcat administration console.

like image 34
Audrius Meškauskas Avatar answered Nov 15 '22 06:11

Audrius Meškauskas