gh-pages -d dist overwrites custom domain
hyperh opened this issue ยท 7 comments
When I use my npm script like so
"deploy": "npm run build:prod && gh-pages -d dist"
My custom domain is overwritten by gh-pages
to be my default Github Pages project domain. I have to go into my Github project settings and make the domain my custom domain every time.
Seems like adding CNAME
to the root of my dist
directory fixes things. My CNAME file has the following content:
mycustomurl.com
I noticed that create-react-app was removing the CNAME from the /build folder and solved it like this: "deploy": "yarn run build && echo 'sigr.online' > ./build/CNAME && gh-pages -d build"
Also noticed that if you add the CNAME file inside the /public
folder, create-react-app will include it in the build output.
Had the same issue with GatsbyJS. Putting the CNAME file into the static folder solved it.
I was facing the same issue and solved it with the following scripts within package.json
:
"scripts": {
"predeploy": "yarn build && cp CNAME ./dist",
"deploy": "gh-pages -d dist"
}
I'm having the same issue with a Lerna repository + Docusaurus publishing via wrapper on https://github.com/microsoft/fast-dna which has my CNAME file inside the root of the project. Though, I'm starting to think it actually needs to be in the root of what gh-pages sees as the branch, so I will try this next.
For angular 8.
Create a CNAME file inside the src folder.
then Inside angular.json
"assets": [
"src/favicon.ico",
"src/assets",
"src/CNAME" // This is the change you need to make.
],
I had the same issue with Gatsby, so I added the CNAME
file to the root directory and changed the deployment script in package.json
to this line: "deploy": "gatsby build --prefix-paths && cp CNAME public && gh-pages -d public -b master"
and it worked.