How to deploy a React App on Apache web server

后端 未结 8 2156
谎友^
谎友^ 2020-11-29 18:11

I have created a basic React App from https://www.tutorialspoint.com/reactjs/reactjs_jsx.htm here , I want to run this test code on Apache based server, I know that I need t

8条回答
  •  清歌不尽
    2020-11-29 18:53

    First, add a pom.xml and make it a maven project and then build it. It will create a War file for you in the target folder after that you can deploy it wherever you want.

    pom.xml http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 it.megadix create-react-app-servlet 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 install (initialize)
                        
                            exec
                        
                        initialize
                        
                            npm
                            
                                install
                            
                        
                    
                    
                    
                        npm install (clean)
                        
                            exec
                        
                        pre-clean
                        
                            npm
                            
                                install
                            
                        
                    
    
                    
                    
                        npm run build (compile)
                        
                            exec
                        
                        compile
                        
                            npm
                            
                                run
                                build
                            
                        
                    
    
                
    
                
                    
                        true
                        
                        ${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://my-awesome-production-host/${project.artifactId}
                                /${project.artifactId}
                            
                        
                    
                
            
        
    
    

    Note:- If you find a blank page after running your project then clear your cache or restart your IDE.

提交回复
热议问题