我过去曾使用Gitlab页面进行反应部署,除了VueJS之外,它们工作得很好。在遵循这里示例之后,即使在Gitlab CI管道成功之后,我仍然无法为GitLab页面生成一个网站链接。有人能帮忙吗?
这就是..gitlab ci.yml的样子:
# .gitlab-ci.yml file to be placed in the root of your repository
pages: # the job must be named pages
image: node:latest
stage: deploy
script:
- npm ci
- npm run build
- mv public public-vue # GitLab Pages hooks on the public folder
- mv dist public # rename the dist folder (result of npm run build)
artifacts:
paths:
- public # artifact path must be /public for GitLab Pages to pick it up
only:
- master
这就是vue.config.js的样子:
// vue.config.js file to be place in the root of your repository
// make sure you update `yourProjectName` with the name of your GitLab project
module.exports = {
publicPath: process.env.NODE_ENV === 'production'
? '/yourProjectName/'
: '/'
}
提交并推送我的更改后,GitLab CI管道从运行改为成功。我本来希望在Settings > Pages
上看到我的网站链接。我点击了它,但我没看到。有什么不对的?
发布于 2022-09-06 21:14:19
可能是资产链接的问题:因为在本地主机上正常,所以所有js文件都位于公用文件夹中,在这个文件夹中,您可以使用/ assets /vuejs.files.js与您的.html页面进行响应或vuejs项目的连接,因此在部署时,您需要重新设置url。
这是vite项目部署https://vitejs.dev/guide/static-deploy.html的文档,其中说明您需要重新设置url,例如:对于您来说,localhost:8000/所有文件都在localhost中:8000/assets/tranovered.vue.js,但是部署您的url与https://gitlab.com/<USERNAME>/<REPO>
不同,因为您的基本URL是'/<REPO>/'
。
要做到这一点,更改,如果不是构建项目,将请求您的资产文件到/ default base url,但不存在,将重定向到gitlab,并将此重定向到登录,因此这是您的问题CORS。
https://stackoverflow.com/questions/55615522
复制相似问题