how to deploy react app in tomcat server code example

Example 1: how to deploy react app in tomcat server

{
  "name": "App",
  "version": "0.1.0",
   "homepage":"http://localhost:8080/sampleapp",
  "private": true,
  "dependencies": {
    "react": "^16.3.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

Example 2: how to deploy react app in tomcat server

import React, { Component } from 'react';
import {
    BrowserRouter,
    Link,
    Route,
    Switch
} from 'react-router-dom';
 
import Home from './Home.jsx';
import ContactUs from './ContactUs.jsx';
import Blog  from './Blog.jsx';
 
class App extends Component {
  render() {
    return (
      

Welcome to React

  • Home
  • Blog
  • Contact Us
); } } export default App;

Example 3: how to deploy react app in tomcat server


 
  frugalis
 
  
    404
    /index.html
  
  

Example 4: how to deploy react app in tomcat server


   
    4.0.0
    com.frugalis
    Frugalis
    0.0.1-SNAPSHOT
    war
 
    
        UTF-8
        build
    
 
    
        ${project.artifactId}
        
            
                org.apache.maven.plugins
                maven-war-plugin
                2.1.1
                
                    
                        
                            ${npm.output.directory}
                        
                    
                    ${basedir}/web.xml
                
            
 
            
                org.codehaus.mojo
                exec-maven-plugin
                1.3.2
                
                    
                        npm run build (compile)
                        
                            exec
                        
                        compile
                        
                            npm
                            
                                run
                                build
                            
                        
                    
 
                
 
                
                    
                        false
                        
                        ${basedir}/npm
                        ${NPM_CONFIG_PREFIX}/cache
                        ${project.build.directory}/npmtmp
                    
                
            
        
    
 
    
        
            local
            
                true
            
            
                
                    
                        org.codehaus.mojo
                        exec-maven-plugin
 
                        
                            
                                http://localhost:8080/${project.artifactId}
                                /${project.artifactId}
                            
                        
                    
                
            
        
 
        
            prod
            
                
                    
                        org.codehaus.mojo
                        exec-maven-plugin
 
                        
                            
                                http://frugalisminds.com/${project.artifactId}
                                /${project.artifactId}
                            
                        
                    
                
            
        
    

Example 5: react tomcat


   
    4.0.0
    com.frugalis
    Frugalis
    0.0.1-SNAPSHOT
    war
 
    
        UTF-8
        build
    
 
    
        ${project.artifactId}
        
            
                org.apache.maven.plugins
                maven-war-plugin
                2.1.1
                
                    
                        
                            ${npm.output.directory}
                        
                    
                    ${basedir}/web.xml
                
            
 
            
                org.codehaus.mojo
                exec-maven-plugin
                1.3.2
                
                    
                        npm run build (compile)
                        
                            exec
                        
                        compile
                        
                            npm
                            
                                run
                                build
                            
                        
                    
 
                
 
                
                    
                        false
                        
                        ${basedir}/npm
                        ${NPM_CONFIG_PREFIX}/cache
                        ${project.build.directory}/npmtmp
                    
                
            
        
    
 
    
        
            local
            
                true
            
            
                
                    
                        org.codehaus.mojo
                        exec-maven-plugin
 
                        
                            
                                http://localhost:8080/${project.artifactId}
                                /${project.artifactId}
                            
                        
                    
                
            
        
 
        
            prod
            
                
                    
                        org.codehaus.mojo
                        exec-maven-plugin
 
                        
                            
                                http://frugalisminds.com/${project.artifactId}
                                /${project.artifactId}
                            
                        
                    
                
            
        
    

Tags:

Misc Example