Skip to content

Commit

Permalink
dedupe up some code
Browse files Browse the repository at this point in the history
  • Loading branch information
kushagharahi committed Aug 14, 2023
1 parent d2375f1 commit 681bebc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
11 changes: 2 additions & 9 deletions .github/workflows/.lighthouserc.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
const paths = require('../../build/paths');

const baseUrl = 'http://127.0.0.1:8080'
// We want paths with the trailing slash so the paths are the prerendered static pages, not javascript pages.
const pathsWithTrailingSlash = paths.map((path) => {
if (path !== '/') {
return `${path}/`
} else {
return path
}
})

module.exports = {
ci: {
collect: {
numberOfRuns: 1,
url: pathsWithTrailingSlash.map((path) => baseUrl + path),
// We want paths with the trailing slash so the paths are the prerendered static pages, not javascript pages.
url: paths.pathsWithTrailingSlash.map((path) => baseUrl + path),
startServerCommand: 'npx http-server dist -p 8080',
},
upload: {
Expand Down
10 changes: 9 additions & 1 deletion build/paths.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = [
module.exports.paths = [
'/',
'/blog',
'/open-source',
Expand All @@ -14,3 +14,11 @@ module.exports = [
'/blog/wanhao_d6_config',
'/blog/playing_with_stable_diffusion_xl',
]

module.exports.pathsWithTrailingSlash = this.paths.map((path) => {
if (path !== '/') {
return `${path}/`
} else {
return path
}
})
14 changes: 3 additions & 11 deletions build/webpack.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,6 @@ const SitemapPlugin = require('sitemap-webpack-plugin').default
const PrerendererWebpackPlugin = require('@prerenderer/webpack-plugin')
const paths = require('./paths')

// We want paths with the trailing slash for building the Sitemap.xml so the paths are the prerendered static pages, not javascript pages.
const pathsWithTrailingSlash = paths.map((path) => {
if (path !== '/') {
return `${path}/`
} else {
return path
}
})

module.exports = merge(common, {
mode: 'production',
devServer: {
Expand Down Expand Up @@ -45,13 +36,14 @@ module.exports = merge(common, {
}),
new SitemapPlugin({
base: 'https://kusha.me',
paths: pathsWithTrailingSlash,
// We want paths with the trailing slash for building the Sitemap.xml so the paths are the prerendered static pages, not javascript pages.
paths: paths.pathsWithTrailingSlash,
options: {
skipgzip: true,
},
}),
new PrerendererWebpackPlugin({
routes: paths,
routes: paths.paths,
rendererOptions: {
//headless: false,
//maxConcurrentRoutes: 1,
Expand Down

0 comments on commit 681bebc

Please sign in to comment.