-
Notifications
You must be signed in to change notification settings - Fork 2
/
next.config.js
38 lines (32 loc) · 903 Bytes
/
next.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const fs = require('fs');
const PrebuildPlugin = require('prebuild-webpack-plugin');
function createGoogleSearchVerificationFile() {
const googleSearchConsoleKey = process.env.GOOGLE_SEARCH_CONSOLE_KEY;
if (!googleSearchConsoleKey) {
return;
}
const filePath = `./public/${googleSearchConsoleKey}.html`;
const content = `google-site-verification: ${googleSearchConsoleKey}.html`;
fs.writeFileSync(filePath, content, (error) => {
if (error) {
console.error(`Could not write file ${filePath}: ${error}`);
}
});
}
module.exports = {
images: {
domains: ['avatars.githubusercontent.com'],
},
webpack: (config, { dev, isServer }) => {
if (!dev && isServer) {
config.plugins.push(
new PrebuildPlugin({
build: () => {
createGoogleSearchVerificationFile();
},
}),
);
}
return config;
},
};