hugoPlugin will fail to load the config ( resulting in the stack below ) because the request to read the config doesn't include the path to the app dir.
an alternative fix might be to remove the configFile filtering at the top of getHugoConfig(), and then the configFile could be an absolute path. ( readFileSync will fail if the file doesnt exist anyway )
failed to load config from ... vite.config.js
error during build:
Error: ENOENT: no such file or directory, open 'config.toml'
at Object.readFileUtf8 (node:internal/fs/sync:25:18)
at readFileSync (node:fs:441:19)
at getHugoConfig (/Users/ionous/Dev/shift/shift-docs/node_modules/vite-hugo-plugin/dist/index.js:71:51)
at hugoPlugin (/Users/ionous/Dev/shift/shift-docs/node_modules/vite-hugo-plugin/dist/index.js:91:22)
at file:///Users/ionous/Dev/shift/shift-docs/vite.config.js.timestamp-1710057699029-eb224d5f316f.mjs:11:5
at ModuleJob.run (node:internal/modules/esm/module_job:217:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
at async loadConfigFromBundledFile (file:///Users/ionous/Dev/shift/shift-docs/node_modules/vite/dist/node/chunks/dep-G-px366b.js:68182:21)
at async loadConfigFromFile (file:///Users/ionous/Dev/shift/shift-docs/node_modules/vite/dist/node/chunks/dep-G-px366b.js:68037:28)
at async resolveConfig (file:///Users/ionous/Dev/shift/shift-docs/node_modules/vite/dist/node/chunks/dep-G-px366b.js:67649:28)
when
appDir
points to a subdirectory:hugoPlugin will fail to load the config ( resulting in the stack below ) because the request to read the config doesn't include the path to the app dir.
https://github.com/DcBD/vite-hugo-plugin/blob/58ff891eafedb086ad4869745121a0efe0606e2a/src/utils/get-hugo-config.ts#L33
modifying the line as follows, seems to fix the issue.
an alternative fix might be to remove the configFile filtering at the top of
getHugoConfig()
, and then the configFile could be an absolute path. (readFileSync
will fail if the file doesnt exist anyway )