【问题标题】:React built application referencing files incorrectly with Parcel and CRA使用 Parcel 和 CRA 反应构建的应用程序引用文件不正确
【发布时间】:2020-04-16 20:07:43
【问题描述】:

更新:我发现 index.html 错误地链接了文件,就像它无法识别文件的存储位置一样。我更正了捆绑文档标题中的 css 链接标记,但现在我仍然遇到 JavaScript 错误,我看不到如何修复它们,因为它的地图非常大。

每当我使用 react-scripts 构建我的 CRA 应用程序并运行我得到的文档时

我几乎 95% 确定这是因为 react-bootstrap。只是想知道是否有其他人遇到这些问题以及是否有解决方法?

这是我的依赖项

{
  "name": "test-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "bootstrap": "^4.4.1",
    "gh-pages": "^2.2.0",
    "react": "^16.13.1",
    "react-bootstrap": "^1.0.0",
    "react-dom": "^16.13.1",
    "react-router-dom": "^5.1.2",
    "react-scripts": "3.4.1",
    "reactstrap": "^8.4.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "deploy": "gh-pages -d build"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

【问题讨论】:

    标签: reactjs react-bootstrap parceljs react-scripts


    【解决方案1】:

    在这里找到答案:

    https://github.com/parcel-bundler/parcel/issues/470#issuecomment-354734896

    事实证明,您需要在使用 Parcel 的构建命令中指定引用文件前面不应有 /。

    如果该链接被删除,这就是我所引用的:

    对不起,我忘了点尝试包裹构建 index.html --public-url ./ 这也记录在文档网站上:https://parceljs.org/production.html

    【讨论】:

      猜你喜欢
      • 2020-08-28
      • 2021-01-19
      • 1970-01-01
      • 2018-10-26
      • 2019-01-18
      • 2021-04-01
      • 2022-07-22
      • 2021-04-19
      • 2013-12-10
      相关资源
      最近更新 更多