Skip to content

Commit

Permalink
fix: replace chunkFileNames logic (#6675)
Browse files Browse the repository at this point in the history
  • Loading branch information
gioboa authored Jul 11, 2024
1 parent 3c5e5a7 commit 9292a59
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/qwik/src/optimizer/src/plugins/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down

0 comments on commit 9292a59

Please sign in to comment.