Reputation: 160
I'm building a website using SvelteKit
, scaffolded using pnpm create svelte
. However, when I run pnpm build
, I get the following error:
vite v3.0.9 building for production...
✓ 77 modules transformed.
.svelte-kit/output/client/vite-manifest.json 2.96 KiB
[vite-plugin-svelte-kit] Error running plugin hook writeBundle for vite-plugin-svelte-kit, expected a function hook.
error during build:
Error: Error running plugin hook closeBundle for vite-plugin-svelte-kit, expected a function hook.
at error (file:///home/leo/code/keo-website/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/rollup.js:1858:30)
at throwInvalidHookError (file:///home/leo/code/keo-website/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/rollup.js:22551:12)
at file:///home/leo/code/keo-website/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/rollup.js:22692:24
at async Promise.all (index 0)
at async Object.close (file:///home/leo/code/keo-website/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/rollup.js:23662:13)
at async Promise.all (index 0)
at async build (file:///home/leo/code/keo-website/node_modules/.pnpm/[email protected][email protected]/node_modules/vite/dist/node/chunks/dep-0fc8e132.js:43473:13)
at async CAC.<anonymous> (file:///home/leo/code/keo-website/node_modules/.pnpm/[email protected][email protected]/node_modules/vite/dist/node/cli.js:747:9)
ELIFECYCLE Command failed with exit code 1.
Here is my svelte.config.js
:
import adapter from "@sveltejs/adapter-static";
import preprocess from "svelte-preprocess";
/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://github.com/sveltejs/svelte-preprocess
// for more information about preprocessors
preprocess: preprocess({
scss: { includePaths: ["./src/styles"] },
}),
kit: {
adapter: adapter({
pages: "build",
assets: "build",
}),
},
};
export default config;
Most things that I've done here are what I've done in the past. The only difference is that I have a export const prerender = true;
in src/routes/+layout.svelte
since it appears that they overhauled their route system.
Upvotes: 5
Views: 6059
Reputation: 721
Edit:
Vite 3.1.0 is out now, if you just npm update
the project it should be fine
Original answer:
This is because in order to fix import.meta.glob
issues with vite they needed to require Vite 3.1.0-beta.1 #6398
The error log mentions writeBundle
which is a Rollup hook that Vite plugins can run.
You can fix the error by manually updating your package.json
to contain
{
...
"devDependencies": {
...
"vite": "^3.1.0-beta.1"
}
}
But this Vite version 3.1.0 will soon be released which will then allow to fix the problem with a simple npm update
Upvotes: 7