-
Notifications
You must be signed in to change notification settings - Fork 27
/
gatsby-node.js
56 lines (50 loc) · 1.17 KB
/
gatsby-node.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const FaviconsWebpackPlugin = require('favicons-webpack-plugin');
const merge = require('lodash/merge');
const defaultOptions = {
logo: './src/favicon.png',
emitStats: true,
statsFilename: '.iconstats.json',
persistentCache: true,
inject: false,
appName: null,
appDescription: null,
developerName: null,
developerURL: null,
dir: 'auto',
lang: 'en-US',
background: '#fff',
theme_color: '#fff',
display: 'standalone',
orientation: 'any',
start_url: '/?homescreen=1',
version: '1.0',
icons: {
android: true,
appleIcon: true,
appleStartup: true,
coast: false,
favicons: true,
firefox: true,
opengraph: false,
twitter: false,
yandex: false,
windows: false,
},
};
function isHtmlStage(stage) {
return stage === 'develop-html' || stage === 'build-html';
}
function getOptions(options) {
let finalOptions = {};
merge(finalOptions, defaultOptions, options);
return finalOptions;
}
module.exports.onCreateWebpackConfig = ({ actions, stage }, options) => {
if (isHtmlStage(stage)) {
actions.setWebpackConfig({
plugins: [
new FaviconsWebpackPlugin(getOptions(options)),
],
});
}
};