Skip to content

Est-ce que j'ai besoin de l'installation de node sur le serveur tomcat pour déployer un exemple de code de site web react.

Si vous rencontrez un détail qui vous fait douter, vous pouvez le commenter et nous ferons tout le nécessaire pour vous aider le plus rapidement possible.

Exemple 1 : comment déployer une application react dans un serveur tomcat.

importReact,{Component}from'react';import{BrowserRouter,Link,Route,Switch}from'react-router-dom';importHomefrom'./Home.jsx';importContactUsfrom'./ContactUs.jsx';importBlogfrom'./Blog.jsx';classAppextendsComponent{render(){return(<div className="App"><div className="App-header"><h2>Welcome to React</h2></div><BrowserRouter basename={process.env.REACT_APP_ROUTER_BASE||''}><div><ul className="nav"><li><Link to="/">Home</Link></li><li><Link to="/blog">Blog</Link></li><li><Link to="/contactUs">ContactUs</Link></li></ul><Switch><Route path="/blog" component={Blog}/><Route path="/contactUs" component={ContactUs}/><Route path="/" component={Home}/></Switch></div></BrowserRouter></div>);}}exportdefaultApp;

Exemple 2 : comment déployer react app dans le serveur tomcat.

<span style="font-family: helvetica, arial, sans-serif;"><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.frugalis</groupId><artifactId>Frugalis</artifactId><version>0.0.1-SNAPSHOT</version><packaging>war</packaging><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><npm.output.directory>build</npm.output.directory></properties><build><finalName>${project.artifactId}</finalName><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-war-plugin</artifactId><version>2.1.1</version><configuration><webResources><resource><directory>${npm.output.directory}</directory></resource></webResources><webXml>${basedir}/web.xml</webXml></configuration></plugin><plugin><groupId>org.codehaus.mojo</groupId><artifactId>exec-maven-plugin</artifactId><version>1.3.2</version><executions><execution><id>npm run build(compile)</id><goals><goal>exec</goal></goals><phase>compile</phase><configuration><executable>npm</executable><arguments><argument>run</argument><argument>build</argument></arguments></configuration></execution></executions><configuration><environmentVariables><CI>false</CI><!--The following parameters create an NPM sandbox forCI--><NPM_CONFIG_PREFIX>${basedir}/npm</NPM_CONFIG_PREFIX><NPM_CONFIG_CACHE>${NPM_CONFIG_PREFIX}/cache</NPM_CONFIG_CACHE><NPM_CONFIG_TMP>${project.build.directory}/npmtmp</NPM_CONFIG_TMP></environmentVariables></configuration></plugin></plugins></build><profiles><profile><id>local</id><activation><activeByDefault>true</activeByDefault></activation><build><plugins><plugin><groupId>org.codehaus.mojo</groupId><artifactId>exec-maven-plugin</artifactId><configuration><environmentVariables><PUBLIC_URL>http://localhost:8080/${project.artifactId}</PUBLIC_URL><REACT_APP_ROUTER_BASE>/${project.artifactId}</REACT_APP_ROUTER_BASE></environmentVariables></configuration></plugin></plugins></build></profile><profile><id>prod</id><build><plugins><plugin><groupId>org.codehaus.mojo</groupId><artifactId>exec-maven-plugin</artifactId><configuration><environmentVariables><PUBLIC_URL>http://frugalisminds.com/${project.artifactId}</PUBLIC_URL><REACT_APP_ROUTER_BASE>/${project.artifactId}</REACT_APP_ROUTER_BASE></environmentVariables></configuration></plugin></plugins></build></profile></profiles></project></span>



Utilisez notre moteur de recherche

Ricerca
Generic filters

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée.