37
loading...
This website collects cookies to deliver better user experience
node_modules
folder and reinstall npm modules. This is optional and should be done if deployment haven't worked for you previously (e.g. the following error appeared: 'fatal: Couldn't find remote ref refs/heads/gh-pages'
).package.json
file.gh-pages
as devDependencies.npm i --save-dev gh-pages // -> using npm
yarn add -D gh-pages // -> using yarn
gh-pages
module helps with deploying the application and it creates a branch where we want to deploy our code. That is why there is no need to create a branch manually.{
"homepage": "https://[GITHUB_USER].github.io/[GITHUB_REPOSITORY_NAME]"
}
{
"predeploy": "npm run build", // or yarn build
"deploy": "gh-pages -b gh-deploy -d build",
}
gh-pages
deploy
it automatically runs predeploy
first. Also, the code that was built with predeploy
command is deployed to thegh-deploy
branch.{
"homepage": "https://[GITHUB_USER].github.io/[GITHUB_PROJECT]",
...
"scripts": {
"predeploy": "npm run build", // or yarn build
"deploy": "gh-pages -b gh-deploy -d build",
...
},
...
"devDependencies": {
"gh-pages": "^3.2.3"
},
...
}