reactjs Gitlab Pages CI - React应用程序构建

ldioqlga  于 2023-11-18  发布在  React
关注(0)|答案(1)|浏览(107)

我有一个项目仓库,由后端目录和React应用程序前端组成。我希望应用程序从Gitlab页面提供。

MyRepo/
├─ frontend/
│  ├─ src/
│  │  ├─ App.js
│  │  ├─ index.js
│  │  ├─ ...
│  │  ├─ ..
│  │  ├─ .
│  ├─ package.json
├─ backend/
├─ .gitignore
├─ README.md
├─ gitlab-ci.yml
|...
|..
|.

字符串
如果React项目是仓库根,我可以轻松地部署它:

image: node

pages:
 stage: deploy
 cache:
   paths:
     - node_modules/
 script:
   - npm install
   - npm run build
   - rm -rf public
   - cp build/index.html build/404.html
   - mv build public
 artifacts:
   paths:
     - public
 only:
   - master


我成功地测试过了
但它不是。我试过了:

image: node

pages:
 stage: deploy
 cache:
   paths:
     - node_modules/
 script:
   - cd frontend # This
   - npm install
   - npm run build
   - rm -rf public
   - cp build/index.html build/404.html
   - mv build public
 artifacts:
   paths:
     - public
 only:
   - master


但失败了。如何正确地部署一个远程控制器?

wn9m85ua

wn9m85ua1#

build文件夹移动到存储库的根目录下,因为工件应该位于项目根目录下的public文件夹中:

image: node

pages:
 stage: deploy
 cache:
   paths:
     - node_modules/
 script:
   - cd frontend
   - npm install
   - npm run build
   - rm -rf public
   - cp build/index.html build/404.html
   - mv build ../public # this change here
 artifacts:
   paths:
     - public
 only:
   - master

字符串

相关问题