Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,25 @@ const { getTitle } = require('../../helpers/getTitle');

const templateDir = path.join(__dirname, '../../templates');

async function getHtmlWebpackPlugin({
isProd,
googleAnalyticsID,
algolia,
url,
title,
isFullscreen
}) {
async function getHtmlWebpackPlugin({ isProd, googleAnalyticsID, algolia, url, title, isFullscreen }) {
return new HtmlWebpackPlugin({
template: path.join(templateDir, 'html.ejs'),
filename: `${url}/index.html`.replace(/^\/+/, ''),
templateParameters: {
title: getTitle(title),
// Don't prerender fullscreen pages (expensive!)
prerendering: (isProd && !isFullscreen && !url.includes('topology') && !url.includes('extensions')) ? await prerender(url) : null,
prerendering:
isProd && !isFullscreen && !url.includes('chatbot') && !url.includes('topology') && !url.includes('extensions')
? await prerender(url)
: null,
// Don't use GA in dev mode
googleAnalyticsID: isProd ? googleAnalyticsID : false,
algolia
},
scriptLoading: 'defer',
inject: false,
minify: false
})
});
}

async function getHtmlWebpackPlugins(options) {
Expand All @@ -40,11 +36,11 @@ async function getHtmlWebpackPlugins(options) {
filename: 'sitemap.xml',
templateParameters: {
urls: Object.entries(routes)
.map(([path, { sources }]) => [path, ...(sources || []).slice(1).map(source => source.slug)])
.map(([path, { sources }]) => [path, ...(sources || []).slice(1).map((source) => source.slug)])
.flat()
},
inject: false,
minify: false,
minify: false
})
];

Expand All @@ -59,7 +55,7 @@ async function getHtmlWebpackPlugins(options) {
.map(([url, { sources = [], title, isFullscreen }]) => [
[url, { title, isFullscreen }],
// Add pages for sources
...sources.slice(1).map(source => [source.slug, source])
...sources.slice(1).map((source) => [source.slug, source])
])
.flat()
.sort();
Expand All @@ -70,7 +66,7 @@ async function getHtmlWebpackPlugins(options) {

console.log('done prerendering');
return res;
};
}

module.exports = {
getHtmlWebpackPlugins
Expand Down
Loading