mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-01 10:22:30 +02:00
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:
parent
ab58eaa9fa
commit
582efb496c
1 changed files with 13 additions and 0 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue