【发布时间】:2020-06-01 21:34:18
【问题描述】:
我正在尝试将我的 React 项目部署到生产环境,似乎 Google App Engine 正在构建开发而不是生产构建文件夹。也许我错过了一些非常简单的东西......
我首先运行“npm run build”,然后运行“npm run deploy”或“gcloud app deploy app.yaml --project [project_name]”
runtime: nodejs
env: flex
env_variables:
APP_ENV: "production"
handlers:
- url: /
static_files: build/index.html
upload: build/index.html
- url: /
static_dir: build
- url: /static
static_dir: build/static
automatic_scaling:
min_num_instances: 2
max_num_instances: 4
cool_down_period_sec: 180
cpu_utilization:
target_utilization: 0.50
resources:
cpu: 1
memory_gb: 3.5
disk_size_gb: 10
这是我的 package.json:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"deploy": "gcloud app deploy app.yaml --project ....",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
当它完成部署时,我仍然会出现开发警告,并且当我运行页面速度时 - js 文件没有被缩小/优化。我错过了什么?
【问题讨论】:
标签: reactjs google-app-engine deployment web-deployment