我正在构建一个新的 Next Js 应用程序,它是使应用程序部署在vercel https://vercel.com/通过链接 gitlab Next js 项目..
对于同一个项目,我需要将其部署在 firebase 中。
我尝试过的事情:
-> 制作firebase init
这给出了firebase.json ,
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}
但上面那个给出了这样的错误,
从这个错误中我可以知道它尝试获取index.html,但我不确定它之后会在哪里npm run build
..
所以我尝试提供页面目录和index.js文件,例如
{
"hosting": {
"public": "pages",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
},
"rewrites": [{
"source": "/pages/**",
"destination": "/index.js"
},
{
"source": "**",
"destination": "/index.js"
}]
}
但这只是打印可用的代码index.js对于用户界面来说,
import React, { Component } from "react";
import Router from "next/router";
export default class Index extends Component {
componentDidMount = () => {
Router.push("/landing",'');
};
render() {
return <div />;
}
}
The gitlab-ci.yml文件如下,
image: node:12.13.0-alpine
stages:
- deploy
cache:
paths:
- node_modules/
key: "$CI_BUILD_REPO"
deploy-prod:
stage: deploy
only:
- master
script:
- npm install
- npm run build
- npm install -g firebase-tools
- firebase -V
- firebase use anvisysytems --token "token_hidden"
- firebase deploy --only hosting -m "Pipe $CI_PIPELINE_ID Build $CI_BUILD_ID" --token "token_hidden"
请帮助我实现获取构建 Next Js 应用程序后生成的正确 index.html 的结果,并使应用程序内容加载到 UI 中,而不是错误(如上图)或代码(如 index.js 代码渲染)在用户界面中)。