Reactjs 在云功能firebase上部署时,页面加载速度非常慢
以前,我在ComputeEngine上部署了我的项目,在那里页面加载没有任何问题。该页面过去加载速度非常快。但是,当我转到无服务器时,页面加载速度非常慢,有时我会收到Reactjs 在云功能firebase上部署时,页面加载速度非常慢,reactjs,firebase,google-cloud-functions,next.js,serverless,Reactjs,Firebase,Google Cloud Functions,Next.js,Serverless,以前,我在ComputeEngine上部署了我的项目,在那里页面加载没有任何问题。该页面过去加载速度非常快。但是,当我转到无服务器时,页面加载速度非常慢,有时我会收到“错误:无法处理请求”。我对无服务器部署信心不足 下面是我如何部署的 结构 .firebase .next public src components pages utils next.config.js server.js .firebaserc firebase.json package.json 配置部分 .fi
“错误:无法处理请求”
。我对无服务器部署信心不足
下面是我如何部署的
结构
.firebase
.next
public
src
components
pages
utils
next.config.js
server.js
.firebaserc
firebase.json
package.json
配置部分
.firebaserc
{
"projects": {
"default": "project-test"
}
}
firebase.json
{
"hosting": {
"public": "public",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
{
"source": "**",
"function": "next"
}
]
},
"functions": {
"source": ".",
"ignore": [
".firebase/**",
".firebaserc",
"firebase.json",
"**/node_modules/**",
"**/.vscode/**",
"**/.hooks/**",
"**/public/**"
]
}
}
next.config.js
const withPlugins = require("next-compose-plugins");
const optimizedImages = require("next-optimized-images");
const withPWA = require("next-pwa");
module.exports = withPlugins(
[optimizedImages],
[
withPWA({
pwa: {
dest: "public",
},
}),
]
);
server.js(我不知道在哪里使用它)
剧本
"scripts": {
"dev:client": "next",
"local": "dotenv -e .env.local next",
"dev:server": "node src/server --source-maps --watch",
"dev": "dotenv -e .env.development yarn dev:client & yarn dev:server",
"build": "dotenv -e .env.production next build",
"build:dev": "dotenv -e .env.development next build",
"build:staging": "dotenv -e .env.staging next build",
"build:production": "NODE_ENV=production dotenv -e .env.production next build",
"deploy:dev": "dotenv -e .env.development firebase deploy --only functions,hosting",
"deploy:staging": "dotenv -e .env.staging firebase deploy -P staging --only functions,hosting",
"start": "next start",
},
我部署的方式是
首先,我使用以下命令构建项目
yarn build:dev
然后使用部署:dev
这是构建文件
部署时我是否错过了任何重要的事情
注意:我正在使用nextjs 9.4请参阅以获取帮助。
yarn build:dev