Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/angry-jokes-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@qwik.dev/core': patch
---

FIX: Qwik vite plugin respects outDir change
4 changes: 2 additions & 2 deletions packages/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@mui/x-data-grid": "8.11.3",
"@qwik-ui/headless": "0.6.7",
"@qwik.dev/core": "workspace:*",
"@qwik.dev/devtools": "0.2.1",
"@qwik.dev/partytown": "0.11.2",
"@qwik.dev/react": "workspace:*",
"@qwik.dev/router": "workspace:*",
Expand Down Expand Up @@ -57,8 +58,7 @@
"valibot": "0.33.3",
"vite": "7.1.11",
"vite-tsconfig-paths": "5.1.4",
"wrangler": "3.65.1",
"@qwik.dev/devtools": "0.2.1"
"wrangler": "3.65.1"
},
"engines": {
"node": "^18.17.0 || ^20.3.0 || >=21.0.0",
Expand Down
19 changes: 16 additions & 3 deletions packages/qwik/src/optimizer/src/plugins/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}): any {
let rootDir: string | null = null;

let ssrOutDir: string | null = null;
// Cache the user-specified clientOutDir to use across multiple normalizeOptions calls
const userClientOutDir = qwikViteOpts.client?.outDir;
// Cache the resolved plugin options from config() to reuse in configResolved()
let cachedPluginOpts: QwikPluginOptions | null = null;
const fileFilter: QwikVitePluginOptions['fileFilter'] = qwikViteOpts.fileFilter
? (id, type) => TRANSFORM_REGEX.test(id) || qwikViteOpts.fileFilter!(id, type)
: () => true;
Expand Down Expand Up @@ -168,9 +172,10 @@ export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}): any {
outDir: viteConfig.build?.outDir,
ssrOutDir: qwikViteOpts.ssr?.outDir || viteConfig.build?.outDir,
clientOutDir:
qwikViteOpts.client?.outDir ||
userClientOutDir ||
// When ssr is true, this is probably an adapter build and not where the client build is
(viteConfig.build?.ssr ? undefined : viteConfig.build?.outDir),
// However, if client.outDir was explicitly set, always use it
(viteConfig.build?.ssr && !userClientOutDir ? undefined : viteConfig.build?.outDir),
assetsDir: useAssetsDir ? viteAssetsDir : undefined,
devTools: qwikViteOpts.devTools,
sourcemap: !!viteConfig.build?.sourcemap,
Expand All @@ -185,6 +190,9 @@ export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}): any {
const opts = await qwikPlugin.normalizeOptions(pluginOpts);
input ||= opts.input;

// Cache pluginOpts for use in configResolved()
cachedPluginOpts = pluginOpts;

manifestInput = opts.manifestInput;
srcDir = opts.srcDir;
rootDir = opts.rootDir;
Expand Down Expand Up @@ -358,7 +366,12 @@ export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}): any {
qwikPlugin.setSourceMapSupport(true);
}
// Ensure that the final settings are applied
qwikPlugin.normalizeOptions(qwikViteOpts);
// Use cachedPluginOpts if available to preserve clientOutDir
if (cachedPluginOpts) {
qwikPlugin.normalizeOptions(cachedPluginOpts);
} else {
qwikPlugin.normalizeOptions(qwikViteOpts);
}
},

async buildStart() {
Expand Down
Loading