如何在生产中删除 Create React 应用程序示例

Tan*_*kar 4 production-environment reactjs create-react-app

我有一个已成功部署在生产服务器中的域。但每当我打开它时,Install app: Create React app sample地址栏中都会显示一个。

有什么办法可以去掉这个吗。我应该在我的代码中更改什么?这里有什么建议吗?

//客户端包.json

{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "axios": "^0.19.2",
    "bootstrap": "^4.4.1",
    "bootstrap-less": "^3.3.8",
    "moment": "^2.24.0",
    "node-sass": "^4.13.1",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "redux-thunk": "^2.3.0",
    "uuid": "^7.0.3"
  },
  "scripts": {
    "start": "react-scripts start",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
    ],
    "development": [
      "last 1 chrome version",
    ]
  },
  "proxy": "http://localhost:5000"
}
Run Code Online (Sandbox Code Playgroud)

//清单.json

{
  "short_name": "React App",
  "name": "Create React App Sample",
  "icons": [
    {
      "src": "favicon.ico",
      "sizes": "64x64 32x32 24x24 16x16",
      "type": "image/x-icon"
    },
    {
      "src": "logo192.png",
      "type": "image/png",
      "sizes": "192x192"
    },
    {
      "src": "logo512.png",
      "type": "image/png",
      "sizes": "512x512"
    }
  ],
  "start_url": ".",
  "display": "standalone",
  "theme_color": "#000000",
  "background_color": "#ffffff"
}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

Gul*_*ain 9

您需要更改manifest.json文件,您可能会在create-react-app创建的public文件夹中找到它。

serviceWorker 使用manifest.json 文件让用户将您的webapp 安装为应用程序,您可以跳过short_name 属性,但您应该提供正确的名称。但跳过两者不会对应用程序的功能造成任何问题,在这种情况下,浏览器将使用您的应用程序的默认名称(即无标题)。

在我的建议中,你应该提供short_name和name财产。

在那里

{
  "short_name": "React App",
  "name": "Create React App Sample", // you need to change this
  "icons": [
    {
      "src": "favicon.ico",
      "sizes": "192x192",
      "type": "image/png"
    }
  ],
  "start_url": "./index.html",
  "display": "standalone",
  "theme_color": "#000000",
  "background_color": "#ffffff"
}
Run Code Online (Sandbox Code Playgroud)