Write CNAME file if custom domain

Custom domains in GitHub pages require a CNAME file. This file is automatically created for you if you add a custom
domain to the GitHub pages section of the "Settings" area in a GitHub repo.

However, the way we push to GitHub, we remove all files from a `gh-pages` branch before building and pushing the new
content on a rebuild. This includes removing the CNAME file, even if it was autogenerated when changing the setting.

So, just always create a CNAME file if the domain is a custom domain.
This commit is contained in:
Joel Marcey 2017-07-28 07:40:31 -07:00
parent ab58eaa9fa
commit 582efb496c

View file

@ -385,6 +385,19 @@ function execute() {
fs.copySync(file, targetFile);
}
});
/* Generate CNAME file if the domain is custom */
if (!siteConfig.url.includes("github.io")) { // github.io urls are not custom
let cname = siteConfig.url;
let targetFile =
__dirname +
"/../../build" +
"/" +
siteConfig.projectName +
"/" +
"CNAME";
fs.writeFileSync(cname, targetFile);
}
}
module.exports = execute;