Skip to content

fix: avoid ssr environment collision in void plugin - #188

Merged
cpojer merged 1 commit into
mainfrom
fix/vite-env-test-safe
May 6, 2026
Merged

cpojer merged 1 commit into
mainfrom
fix/vite-env-test-safe

Conversation

@TheAlexLichter

@TheAlexLichter TheAlexLichter commented May 6, 2026 •

Copy link
Copy Markdown
Member

When using the Void Vite plugin, you can't test with Vitest anymore due to a naming collision with the 'ssr' environment.
To resolve this, this PR adds a Void-owned void_worker Vite environment.

The typical output path (dist/ssr) is preserved for default apps.


Current project workaround via Vite config:

import { defineConfig, lazyPlugins } from "vite-plus";
import { voidPlugin } from "void";
import vue from "@vitejs/plugin-vue";
import tailwindcss from "@tailwindcss/vite";
import { fontless } from "fontless";

export default defineConfig({
  plugins: lazyPlugins(() =>
    isTestCommand() ? [] : [vue(), tailwindcss(), fontless(), voidPlugin()],
  ),
  test: {
    include: ["tests/**/*.test.ts"],
  },
});

function isTestCommand(): boolean {
  return process.env.VITEST === "true" || process.argv.some((arg) => arg.includes("test"));
}

@TheAlexLichter
TheAlexLichter marked this pull request as ready for review May 6, 2026 23:07
@TheAlexLichter
TheAlexLichter requested a review from cpojer May 6, 2026 23:09
@cpojer
cpojer merged commit 2ac7b1d into main May 6, 2026
9 checks passed
@cpojer
cpojer deleted the fix/vite-env-test-safe branch May 6, 2026 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants