-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
buildStart
is called 3 times in a row
#262
Comments
No this is as expected. A SolidStart app is made of three vite subapps (a client app, a server app and server functions app). If you apply a vite plugin normally, it will be applied to all three subapps, thus will run thrice. You can use solid-start's eg. import { defineConfig } from "@solidjs/start/config";
export default defineConfig({
vite({ router }) {
if (router === "server") {
} else if (router === "client") {
} else if (router === "server-function") {
}
return { plugins: [] };
}
}); |
Wait why is buildStart even called during |
That makes sense, I didn't know that, thanks
What should I use instead? If |
So you would do two things, one to configure the dev server (watcher), and for the build. You want to hook into the vinxi app hooks 'build:start' event. Right now the way to do this is like this. const app = defineConfig({ ... });
// add a hook to the app before exporting it
app.hooks.hook('app:build:start', async () => {
await main()
})
/**
*
* @returns {import('vinxi').PluginOption}
*/
function openAPIPlugin() {
return {
name: "fs-watcher",
async configureServer(server) {
// run it once at the beginning
await main();
server.watcher.add(sourceDir)
server.watcher.on('change', async (file) => {
if (file.startsWith(sourceDir))
// run it again on change
await main();
})
}
};
}
export default app; Please note this probably to being able to add a hook via config directly (and simpler names like "build:start" instead of "app:build:start" |
I have made a custom plugin that compiles my openapi yamls to javascript files and it worked fine with vite until i switched to vinxi and vite 5.0. Know my plugin is executed 3 times in a row and parralell which doesn't make any sense:
This is roughly my code and when i start
pnpm dev
i get following in the console:Am I doing something wrong or is this a bug?
Note:
This only happens with
pnpm dev
. When usingpnpm build
everything works fine and buildStart is called only once.The text was updated successfully, but these errors were encountered: