You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{defineConfig,squooshImageService}from'astro/config';importoramafrom"@orama/plugin-astro";// https://astro.build/configexportdefaultdefineConfig({site: "https://astro.build",image: {service: squooshImageService()},output: "hybrid",integrations: [orama({// We can generate more than one DB, with different configurationsmydb: {// Required. Only pages matching this path regex will be indexedpathMatcher: /.*/,// Optional. 'english' by defaultlanguage: 'english',// Optional. ['body'] by default. Use it to constraint what is used to// index a page.contentSelectors: ['h1','main']}}),],});
The specific bug you get is this
...
ENOENT: no such file or directory, open 'undefineddist/about/index.html'
Stack trace:
at readFileSync (node:fs:456:20)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async withTakingALongTimeMsg (file:///workspace/astro/node_modules/.pnpm/astro@4.2.4_sass@1.70.0_typescript@5.3.3/node_modules/astro/dist/integrations/index.js:23:18)
at async AstroBuilder.build (file:///workspace/astro/node_modules/.pnpm/astro@4.2.4_sass@1.70.0_typescript@5.3.3/node_modules/astro/dist/core/build/index.js:149:5)
at async build (file:///workspace/astro/node_modules/.pnpm/astro@4.2.4_sass@1.70.0_typescript@5.3.3/node_modules/astro/dist/core/build/index.js:47:3)
at async runCommand (file:///workspace/astro/node_modules/.pnpm/astro@4.2.4_sass@1.70.0_typescript@5.3.3/node_modules/astro/dist/cli/index.js:127:7)
I've reduced the issue to be due to the ways Orama selects the base URL for the built HTML files when analyzing, in fact I find the approach kind of odd since Astro now supports the baseURL directly via dir, I'm assuming this was due to an older version of Astro.
The way the Astro orama plugin currently selects the baseURL is basically to look through all the routes of the build including endpoint routes (which do NOT have a destination URL), the orama plugin then selects the first route and checks the destination URL, but Astro automatically pushes the image endpoint routes to being the first route when using an image service, which messes up the baseURL Orama uses, thus the fix is to just rely on Astro to give us the baseURL.
The solution for this issue is to just use the baseURL Astro provides in the astro:build:done hook like so const basePath = dir.pathname.slice(isWindows ? 1 : 0);
Describe the bug
When you use a image service in Astro, a-la
The specific bug you get is this
... ENOENT: no such file or directory, open 'undefineddist/about/index.html' Stack trace: at readFileSync (node:fs:456:20) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async withTakingALongTimeMsg (file:///workspace/astro/node_modules/.pnpm/astro@4.2.4_sass@1.70.0_typescript@5.3.3/node_modules/astro/dist/integrations/index.js:23:18) at async AstroBuilder.build (file:///workspace/astro/node_modules/.pnpm/astro@4.2.4_sass@1.70.0_typescript@5.3.3/node_modules/astro/dist/core/build/index.js:149:5) at async build (file:///workspace/astro/node_modules/.pnpm/astro@4.2.4_sass@1.70.0_typescript@5.3.3/node_modules/astro/dist/core/build/index.js:47:3) at async runCommand (file:///workspace/astro/node_modules/.pnpm/astro@4.2.4_sass@1.70.0_typescript@5.3.3/node_modules/astro/dist/cli/index.js:127:7)
I've reduced the issue to be due to the ways Orama selects the base URL for the built HTML files when analyzing, in fact I find the approach kind of odd since Astro now supports the baseURL directly via
dir
, I'm assuming this was due to an older version of Astro.The way the Astro orama plugin currently selects the baseURL is basically to look through all the routes of the build including endpoint routes (which do NOT have a destination URL), the orama plugin then selects the first route and checks the destination URL, but Astro automatically pushes the image endpoint routes to being the first route when using an image service, which messes up the baseURL Orama uses, thus the fix is to just rely on Astro to give us the baseURL.
The solution for this issue is to just use the baseURL Astro provides in the
astro:build:done
hook like soconst basePath = dir.pathname.slice(isWindows ? 1 : 0);
Hopefully, this helps https://docs.astro.build/en/reference/integrations-reference/#hooks:~:text=%27-,astro%3Abuild%3Adone%27%3F%3A%20(options%3A%20%7B%20dir%3A%20URL,-%3B%20routes%3A%20RouteData%5B%5D%3B%20logger
To Reproduce
astro build
Expected behavior
I expected the correct baseURL should've been used
Environment Info
Affected areas
Data Insertion, Environment/OS
Additional context
This is a small bug in the way orama determines the baseURL when used in Astro. I'll create a quick PR and add it to the issue.
PR #618
The text was updated successfully, but these errors were encountered: