如何在 tomcat 上运行 React 应用程序 [英] How to run a react app on tomcat
本文介绍了如何在 tomcat 上运行 React 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试运行以下示例:https://github.com/ceolter/ag-grid-react-example
I'm trying to run the following example: https://github.com/ceolter/ag-grid-react-example
(ag-grid 反应示例)
(ag-grid react example)
但是,我想在 tomcat 上运行它,而不是执行 npm run
.怎么做?
But, instead of doing npm run
I want to run it on tomcat. How to do it?
推荐答案
您可以轻松地在 Tomcat 上部署任何静态文件.您链接的项目没有用于构建示例生产版本的脚本,因此您需要做的是:
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:
- 在本地安装 webpack:
npm install -g webpack
- 构建演示:
webpack --config webpack.config.standard.js --progress --colors --hot --inline
或webpack --config webpack.config.large.js --progress --colors --hot --inline
.它将创建dist
目录. - 在 Tomcat
webapps
目录中为您的演示ag-grid
创建另一个目录. - 将
index.html
和dist
复制到ag-grid
. - 在
http://host:port/ag-grid
上访问它.
- Install webpack locally:
npm install -g webpack
- Build demo:
webpack --config webpack.config.standard.js --progress --colors --hot --inline
orwebpack --config webpack.config.large.js --progress --colors --hot --inline
. It will createdist
directory. - In Tomcat
webapps
directory create create another directory for your demoag-grid
. - Copy
index.html
anddist
toag-grid
. - Access it on
http://host:port/ag-grid
.
这篇关于如何在 tomcat 上运行 React 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文