From 9292a59acafd1d42c1b032f562a32de28b9983c4 Mon Sep 17 00:00:00 2001 From: Giorgio Boa <35845425+gioboa@users.noreply.github.com> Date: Fri, 12 Jul 2024 00:59:19 +0200 Subject: [PATCH] fix: replace chunkFileNames logic (#6675) --- packages/qwik/src/optimizer/src/plugins/vite.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/qwik/src/optimizer/src/plugins/vite.ts b/packages/qwik/src/optimizer/src/plugins/vite.ts index f575731e94c..2c145086be2 100644 --- a/packages/qwik/src/optimizer/src/plugins/vite.ts +++ b/packages/qwik/src/optimizer/src/plugins/vite.ts @@ -558,23 +558,26 @@ export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}): any { fileName: Q_MANIFEST_FILENAME, source: clientManifestStr, }); + const assetsDir = qwikPlugin.getOptions().assetsDir || ''; + const useAssetsDir = !!assetsDir && assetsDir !== '_astro'; const sys = qwikPlugin.getSys(); - const filePath = sys.path.dirname(_.chunkFileNames as string); this.emitFile({ type: 'asset', - fileName: sys.path.join(filePath, `q-bundle-graph-${manifest.manifestHash}.json`), + fileName: sys.path.join( + useAssetsDir ? assetsDir : '', + 'build', + `q-bundle-graph-${manifest.manifestHash}.json` + ), source: JSON.stringify(convertManifestToBundleGraph(manifest)), }); const fs: typeof import('fs') = await sys.dynamicImport('node:fs'); const workerScriptPath = (await this.resolve('@builder.io/qwik/qwik-prefetch.js'))!.id; const workerScript = await fs.promises.readFile(workerScriptPath, 'utf-8'); - const assetsDir = qwikPlugin.getOptions().assetsDir || ''; - const useAssetsDir = !!assetsDir && assetsDir !== '_astro'; const qwikPrefetchServiceWorkerFile = 'qwik-prefetch-service-worker.js'; this.emitFile({ type: 'asset', fileName: useAssetsDir - ? sys.path.join(filePath, qwikPrefetchServiceWorkerFile) + ? sys.path.join(assetsDir, 'build', qwikPrefetchServiceWorkerFile) : qwikPrefetchServiceWorkerFile, source: workerScript, });