Skip to content

Commit 1290056

Browse files
committed
docs: copy cname after build
1 parent a9b402b commit 1290056

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

CNAME

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
leaflet-geosearch.meijer.works

gatsby-node.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,42 @@
11
/* eslint-disable @typescript-eslint/no-var-requires */
22
const path = require('path');
3+
const fs = require('fs');
4+
5+
const statics = ['CNAME'];
6+
7+
exports.onPostBuild = ({ reporter }) => {
8+
function findRepoRoot(dir = process.cwd()) {
9+
const gitDir = path.join(dir, '.git');
10+
11+
if (fs.existsSync(gitDir)) {
12+
return dir;
13+
}
14+
15+
const parentDir = path.dirname(dir);
16+
if (parentDir === dir) {
17+
return null;
18+
}
19+
20+
return findRepoRoot(parentDir);
21+
}
22+
23+
const root = findRepoRoot();
24+
const dist = path.join(root, '.docz/dist');
25+
26+
console.dir({ root, dist });
27+
for (const file of statics) {
28+
const src = path.resolve(root, file);
29+
const dest = path.resolve(dist, file);
30+
31+
if (!fs.existsSync(src)) {
32+
reporter.info(`File ${file} not found`);
33+
continue;
34+
}
35+
36+
fs.copyFileSync(src, dest);
37+
reporter.info(`Copied ${src}${dest}`);
38+
}
39+
};
340

441
exports.onCreateWebpackConfig = ({ actions, stage, loaders }) => {
542
if (stage === 'build-html' || stage === 'develop-html') {

0 commit comments

Comments
 (0)