Skip to content

Commit 0315573

Browse files
committed
build(config): run pagefind search index during development builds
1 parent 60f50dd commit 0315573

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

eleventy.config.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const pluginFavicon = require('eleventy-favicon')
88
const CleanCSS = require('clean-css')
99
const fs = require('node:fs')
1010
const path = require('node:path')
11+
const { exec } = require('node:child_process')
1112

1213
const pluginImages = require('./eleventy.config.images.js')
1314
const tracToHTML = require('./eleventy.config.tracToHTML.js')
@@ -170,6 +171,22 @@ module.exports = function (eleventyConfig) {
170171
return content.toString()
171172
})
172173

174+
eleventyConfig.on('eleventy.after', async ({ runMode, outputMode }) => {
175+
if (
176+
process.env.NODE_ENV === 'development' &&
177+
runMode === 'serve' &&
178+
outputMode === 'fs'
179+
) {
180+
return exec('npm run searchindex', (err, stdout) => {
181+
if (err) {
182+
console.error(err)
183+
return
184+
}
185+
console.log(stdout)
186+
})
187+
}
188+
})
189+
173190
// Features to make your build faster (when you need them)
174191

175192
// If your passthrough copy gets heavy and cumbersome, add this line

0 commit comments

Comments
 (0)