Skip to content

Como faço pra rodar um react app no github pages? #7

Discussion options

You must be logged in to vote

Para fazer isso precisamos de seguir algumas etapas:

  1. Adicionar homepage ao package.json com o link da URL onde ele estará rodando, ex: https://myuser.github.io/my-repo
  2. Criar script de deploy no package.json -> "deploy": "npm run build && npx gh-pages -d build"
  3. Rodar o comando npm run deploy sempre que quiser atualizar a aplicação

Seque abaixo um exemplo de package.json já com o script de deploy:

{
  "name": "search-zip",
  "homepage": "https://meu-user.github.io/meu-projeto/", // add
  "version": "0.1.0",
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "deploy": "npm run build && npx gh-pages -d build", // add
    "test": "react-scripts test",

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Guilherme-BS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment