antony / sveltekit-adapter-browser-extension

Build browser extensions with Svelte (early prototype)
162 stars 19 forks source link

Setting prerender option in config causes build error #26

Open riverfr0zen opened 1 year ago

riverfr0zen commented 1 year ago

I'm using the latest sveltekit as of writing (sveltejs/kit@1.24.1).

When following the example in the adapter README, I get the following error when building:

error during build:
Error: Unexpected option config.kit.prerender.default
    at file:///app/browser_extension/node_modules/.pnpm/@sveltejs+kit@1.24.1_svelte@4.2.0_vite@4.4.9/node_modules/@sveltejs/kit/src/core/config/options.js:315:12

However, if I remove the config.kit.prerender.default from config, building then fails with a contradictory message:

> Using sveltekit-adapter-browser-extension
  You should set `config.kit.prerender.default` to `true` if no fallback is specified
error during build:
Error: ENOENT: no such file or directory, open 'build/index.html'
    at Object.openSync (node:fs:602:3)
    at readFileSync (node:fs:470:35)

I found a solution that seems to work at https://stackoverflow.com/a/76883793:

Create a routes/+layout.ts file containing the following line:

export const prerender = true;

(And make sure you removed the prerender item from config). Once I did this, I still get a warning, but the extension builds.