【问题标题】:SSG NextJS on Gitlab Pages stucked on 404?Github 页面上的 SSG Next JS 卡在 404 上?
【发布时间】:2020-11-13 00:17:40
【问题描述】:

我开始了一个简单的 SSG NextJS 项目来构建我的个人网站/投资组合:https://gitlab.com/soykje/soykje.gitlab.io,我想使用 Gitlab 页面进行部署(但没有 now 的东西......)。

我创建了 .gitlab-ci.yml 并更新了 next.config.js 以处理 assetPrefix 参数,但我仍然得到一个神秘的 404。我找不到修复它的方法,因为 CI/ CD 告诉我们一切都很好...... :(

这是我的.gitlab-ci.yml

image: node

cache:
  paths:
    - node_modules

before_script:
  - npm install

pages:
  script:
    - npm run publish # eq. to "next build && next export"
    - mv out public
  artifacts:
    paths:
      - public
  only:
    - master

有人在使用 Gitlab Pages 部署静态 NextJS 项目时遇到同样的问题吗?任何帮助都会很棒,提前谢谢!

【问题讨论】:

    标签: gitlab next.js


    【解决方案1】:

    好的,我找到了原因:我没有正确使用mv 命令......所以最后我得到了以下配置,一切运行正常:

    image: node
    
    before_script:
      - npm install
    
    cache:
      paths:
        - node_modules
    
    pages:
      script:
        - npm run publish
        - mv out/* public
        - rm -rf out
      artifacts:
        paths:
          - public
      only:
        - master
    

    希望这会有所帮助!

    【讨论】:

    • 我使用了这条指令,它运行了页面:脚本:- npm run-script build && npm run-script export - rm -rf public/* - mv out/* public
    猜你喜欢
    • 2017-06-14
    • 2019-01-09
    • 2012-07-19
    • 1970-01-01
    • 1970-01-01
    • 2021-12-12
    • 2022-09-23
    • 2017-12-17
    • 2022-12-04
    相关资源
    最近更新 更多