【问题标题】:how does a create-react app work without an index.html?没有 index.html 的 create-react 应用程序如何工作?
【发布时间】:2019-03-21 22:06:06
【问题描述】:

我的 react 应用(我认为它基于 create-react-app - 我最初没有创建它)

不使用 index.html,它有一个 index.js,它有几个 index.js,

我想知道这是如何工作的?基本上,当我运行 npm run build 时,不会创建 build 文件夹,而是创建 es 和 lib 文件夹,它们是 src 文件夹(包含组件)的副本

为什么要创建这两个文件夹而不是构建?

我使用了一个 npm 包:https://www.npmjs.com/package/react-chat-window

这是我的 package.json(可能有线索):

我真的很想了解,因为在我的服务器上,我使用的是 nginx,但它没有路由到任何文件,站点可用/默认不会路由到默认设置的任何地方,所以它是如何工作的!?

{
  "name": "react-chat-window",
  "version": "1.0.8",
  "description": "react-live-chat React component",
  "main": "lib/index.js",
  "module": "es/index.js",
  "files": [
    "css",
    "es",
    "lib",
    "umd"
  ],
  "scripts": {
    "build": "nwb build-react-component --copy-files",
    "clean": "nwb clean-module && nwb clean-demo",
    "start": " nwb serve-react-demo",
    "gh:publish": "nwb build-demo && gh-pages -d demo/dist"
  },
  "dependencies": {
    "@material-ui/core": "^3.2.0",
    "emoji-js": "3.2.2",
    "fs": "0.0.1-security",
    "gh-pages": "^1.0.0",
    "material-ui": "^0.20.2",
    "moment": "^2.24.0",
    "prop-types": "15.5.10",
    "react-highlight.js": "1.0.5",
    "react-slick": "^0.23.2",
    "slick-carousel": "^1.8.1",
    "socket.io-client": "2.0.3"
  },
  "peerDependencies": {
    "react": "16.6.0",
    "react-dom": "^16.6.0"
  },
  "devDependencies": {
    "nwb": "0.17.x",
    "react": "^16.6.0",
    "react-dom": "^16.6.0"
  },
  "author": "",
  "homepage": "",
  "license": "MIT",
  "repository": {
    "type": "git",
    "url": "https://github.com/kingofthestack/react-live-chat.git"
  },
  "keywords": [
    "react-component"
  ]
}

【问题讨论】:

  • 我自己没有使用过 github 页面,但也许这有线索?我可以看到 gh-pages 在你的 package.json 中

标签: javascript reactjs


【解决方案1】:

您没有使用 create-react-app ,您使用的是另一个名为 nwb 的样板,这是他的官方文档以了解它是如何工作的https://github.com/insin/nwb,这是他有关 react 的文档 https://github.com/insin/nwb/blob/master/docs/guides/ReactApps.md#developing-react-apps-with-nwb

【讨论】:

  • 我认为这是我的问题,我一直在寻找 create-react-app 解决方案!谢谢。
猜你喜欢
  • 2018-01-14
  • 1970-01-01
  • 2020-10-06
  • 2022-08-16
  • 2020-10-21
  • 2021-10-21
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多