-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
34 lines (24 loc) · 838 Bytes
/
index.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
'use strict'
const generator = require('./generator');
const path = require('path');
let isRunning = false;
module.exports =
(sitemap = {}) =>
(nextConfig = {}) =>
Object.assign({}, nextConfig, {
webpack(config, options) {
const { isServer, buildId, webpack } = options;
if (typeof nextConfig.webpack === 'function' && isRunning == false) {
config = nextConfig.webpack(config, options)
}
if (isServer && isRunning == false) {
isRunning = true;
console.log('[Sitemap Generator]: Generating Sitemap');
if (typeof sitemap.publicPath === 'undefined') {
sitemap.publicPath = path.join(options.dir, 'public');
}
generator(sitemap);
}
return config;
}
})