-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No way to add plugins that run before internal plugins #383
Comments
my current workaround is this patch diff --git a/lib/build.js b/lib/build.js
index 812f346df2651bb4bab4ef54ac71b8142f15531a..e04fe63ea8219f2cdfc684a48a95a4818a34e1cd 100644
--- a/lib/build.js
+++ b/lib/build.js
@@ -503,6 +503,7 @@ async function createRouterBuild(app, router) {
app,
});
+ await app.hooks.callHook("3m6vP6KyC27N6foZgWisB", viteBuildConfig.plugins);
await createViteBuild(viteBuildConfig);
await app.hooks.callHook("app:build:router:vite:end", {
diff --git a/lib/dev-server.js b/lib/dev-server.js
index 381b6326958e55feb0e611d94c29c2b5e6fc8038..0bfb65120d48b5b76bb6881edfd82cee6f5cf17a 100644
--- a/lib/dev-server.js
+++ b/lib/dev-server.js
@@ -58,6 +58,8 @@ export async function createViteHandler(router, app, serveConfig) {
...(((await router.plugins?.(router)) ?? []).filter(Boolean) || []),
].filter(Boolean);
+ await app.hooks.callHook("3m6vP6KyC27N6foZgWisB", plugins);
+
let base = join(app.config.server.baseURL ?? "/", router.base);
const viteDevServer = await createViteDevServer({ and this in my const app = createApp({ /* ... */ })
app.hooks.hook("3m6vP6KyC27N6foZgWisB", plugins => {
plugins.unshift(/* plugins here */)
})
export default app |
the hook api is meant to be stable in terms of all the hooks we call today .. removing them would be a breaking change now .. their arguments would also remain the same, and the api of the arguments like vite and nitro as as stable as those dependencies themselves . So this is a perfect way to solve this problem. I am surprised the same hooks couldn't be found in dev. On my phone will check and see if I can find the appropriate hook there |
All the hooks haven't been documented but they will not be removed ... docs are coming soon I Would classify it as a bug that there's no hook exposing the vite config before it's used in dev .. Also btw couldn't you add a vite plugin that did these things in its configResolved.. I think you can rearrange plugins etc at that time |
hmm, maybe. but in the types, the received It's good to hear that the hooks are stable though. |
This means Vinxi projects cannot properly integrate other languages like Civet or plugins that need to run on the original source code like
babel-plugin-here
.I did some digging into the source code and found 2 places where the order of the plugins is hardcoded.
For
vinxi build
it's here:vinxi/packages/vinxi/lib/build.js
Lines 477 to 491 in 93d236a
For
vinxi dev
it's here:vinxi/packages/vinxi/lib/dev-server.js
Lines 53 to 59 in 93d236a
I found I could hook into
vinxi build
thanks to:vinxi/packages/vinxi/lib/build.js
Lines 500 to 504 in 93d236a
Like so:
This requires inside knowledge however and I assume this is not stable.
I could not find anything similar for
vinxi dev
.The text was updated successfully, but these errors were encountered: