Skip to content

Commit 3861515

Browse files
back to before handling
1 parent 30e0301 commit 3861515

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/ssr-plugin.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,6 @@ async function renderComponentToSSR(
254254
): Promise<{ html: string }> {
255255
const viteServer = ctx.project.vite;
256256

257-
// vite doesn't replace import.meta.env with hardcoded values so we need to do it manually
258-
for (const [key, value] of Object.entries(viteServer.config.env)) {
259-
// biome-ignore lint/style/noNonNullAssertion: it's always defined
260-
viteServer.config.define![`__vite_ssr_import_meta__.env.${key}`] =
261-
JSON.stringify(value);
262-
}
263-
264257
const qwikModule = await viteServer.ssrLoadModule("@builder.io/qwik");
265258
const { jsx } = qwikModule;
266259
const jsxElement = jsx(Component, props);
@@ -291,6 +284,13 @@ const renderSSRCommand: ComponentFormat = async (
291284
const absoluteComponentPath = resolve(projectRoot, componentPath);
292285

293286
const viteServer = ctx.project.vite;
287+
// vite doesn't replace import.meta.env with hardcoded values so we need to do it manually
288+
for (const [key, value] of Object.entries(viteServer.config.env)) {
289+
// biome-ignore lint/style/noNonNullAssertion: it's always defined
290+
viteServer.config.define![`__vite_ssr_import_meta__.env.${key}`] =
291+
JSON.stringify(value);
292+
}
293+
294294
const componentModule = await viteServer.ssrLoadModule(
295295
absoluteComponentPath,
296296
);
@@ -318,6 +318,12 @@ const renderSSRLocalCommand: LocalComponentFormat = async (
318318
) => {
319319
try {
320320
const viteServer = ctx.project.vite;
321+
// vite doesn't replace import.meta.env with hardcoded values so we need to do it manually
322+
for (const [key, value] of Object.entries(viteServer.config.env)) {
323+
// biome-ignore lint/style/noNonNullAssertion: it's always defined
324+
viteServer.config.define![`__vite_ssr_import_meta__.env.${key}`] =
325+
JSON.stringify(value);
326+
}
321327

322328
// Create a modified version of the test file without vitest imports
323329
const { readFileSync, writeFileSync, unlinkSync } = await import("node:fs");

0 commit comments

Comments
 (0)