You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/index.js
+42-3Lines changed: 42 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,10 @@
1
+
constpath=require('path');
2
+
3
+
constgetCacheDirs=(PUBLISH_DIR)=>[
4
+
PUBLISH_DIR,
5
+
path.normalize(`${PUBLISH_DIR}/../.cache`),
6
+
];
7
+
1
8
// This is the main file for the Netlify Build plugin {{name}}.
2
9
// Please read the comments to learn more about the Netlify Build plugin syntax.
3
10
// Find more information in the Netlify documentation.
@@ -71,8 +78,29 @@ module.exports = {
71
78
},
72
79
}){
73
80
try{
74
-
// Commands are printed in Netlify logs
75
-
awaitrun('echo',['Hello world!\n'])
81
+
// print a helpful message if the publish dir is misconfigured
82
+
if(process.cwd()===PUBLISH_DIR){
83
+
build.failBuild(
84
+
`Gatsby sites must publish the public directory, but your site’s publish directory is set to “${PUBLISH_DIR}”. Please set your publish directory to your Gatsby site’s public directory.`,
85
+
);
86
+
}
87
+
88
+
constcacheDirs=getCacheDirs(PUBLISH_DIR);
89
+
90
+
if(awaitcache.restore(cacheDirs)){
91
+
console.log('Found a Gatsby cache. We’re about to go FAST. ⚡️');
92
+
}else{
93
+
console.log('No Gatsby cache found. Building fresh.');
94
+
}
95
+
96
+
// check gatsby for gatsby-plugin-netlify - log warning WHEN NOT
97
+
98
+
// copying netlify wrapper functions into function dir
99
+
100
+
// copy compiled gatsby functions into function dir
0 commit comments