【问题标题】:Migrating react project dependencies from node to apache将反应项目依赖项从节点迁移到 apache
【发布时间】:2017-07-26 10:04:03
【问题描述】:

我使用create-react-app 创建了一个反应应用程序 但我想将我的应用程序从节点移动到 apache,但我不确定如何处理我的项目的依赖项。例如,material-ui's 文档仅在其安装指南中列出了 npm。

有没有办法让这些依赖项在 apache 服务器上工作?

如果是这样,是否每个依赖项都是单独的配置过程?

package.json

{
  "name": "app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "material-ui": "^0.18.6",
    "npm": "^5.1.0",
    "prop-types": "^15.5.10",
    "react": "^15.6.1",
    "react-dom": "^15.6.1",
    "react-flexbox-grid": "^1.1.3",
    "react-router": "^4.1.1",
    "react-router-dom": "^4.1.1",
    "react-tap-event-plugin": "^2.0.1"
  },
  "devDependencies": {
    "babel-preset-env": "^1.6.0",
    "eslint": "^3.19.0",
    "eslint-config-airbnb": "^15.0.1",
    "eslint-plugin-import": "^2.7.0",
    "eslint-plugin-jsx-a11y": "^5.1.0",
    "eslint-plugin-react": "^7.1.0",
    "react-scripts": "1.0.10"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

【问题讨论】:

  • 你想在 apache 上使用 npm 包吗?您将使用哪种编程语言?纯html和javascript?
  • 是的!我想将这些 npm 包与 apache 一起使用。我还将使用一点 PHP。澄清一下,我已经运行了一个 apache 服务器来提供一些 php 文件,并且我希望 apache 也可以为我的 react 应用程序提供服务。我正在构建一个 web 投资组合网站,我想用 react 来构建它,同时还能展示过去用 php 构建的项目

标签: javascript node.js apache reactjs create-react-app


【解决方案1】:

React 应用程序不依赖于任何特定的服务器技术 - 一旦您的构建运行,它只是静态 JavaScript。

在项目的根目录中运行 npm run build 将创建一个 dist 文件夹,其中包含您的捆绑应用程序 - 您需要做的就是将该文件夹的内容部署到您的 Apache 服务器。

See the 'Deploying' section of the create-react-app README for more info.

顺便说一句 - 如果您一直在生产中使用 create-react-app 的内置服务器,请不要!这只是为开发而设计的,性能和安全性都不足以将您的应用提供给全世界。

【讨论】:

  • @JesseHuang:没问题,很高兴我能帮上忙!确保您也阅读了该 README 文件的其余部分,其中有很多非常有用的东西。
猜你喜欢
  • 1970-01-01
  • 2015-04-05
  • 2019-04-16
  • 2016-12-26
  • 2016-06-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-04-12
相关资源
最近更新 更多