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/clear-shoes-cheat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@qwik.dev/core': minor
---

FEAT: `qwikVite` now accepts `ssr.manifestInputPath` for when the `q-manifest.json` file from the client build is at an unexpected location.
5 changes: 5 additions & 0 deletions .changeset/six-breads-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@qwik.dev/core': major
---

BREAKING: When using the `base` setting in Vite, the client build will no longer be placed under that base path. Instead, the output directory is always `dist/` by default. If you need to change the output directory, use the `build.outDir` setting in Vite or the `outDir` option in the `qwikVite` plugin under `client` or `ssr`.
7 changes: 5 additions & 2 deletions packages/qwik/src/optimizer/src/plugins/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export function createQwikPlugin(optimizerOptions: OptimizerOptions = {}) {
clientOutDir: undefined as any,
sourcemap: !!optimizerOptions.sourcemap,
manifestInput: null,
manifestInputPath: null,
manifestOutput: null,
transformedModuleOutput: null,
scope: null,
Expand Down Expand Up @@ -964,7 +965,8 @@ export const isDev = ${JSON.stringify(isDev)};
maybeFs
) {
const path = getPath();
let clientManifestPath = path.resolve(opts.clientOutDir, Q_MANIFEST_FILENAME);
let clientManifestPath =
opts.manifestInputPath || path.resolve(opts.clientOutDir, Q_MANIFEST_FILENAME);
if (!(await maybeFs.promises.stat(clientManifestPath).catch(() => false))) {
clientManifestPath = path.resolve(opts.rootDir, CLIENT_OUT_DIR, Q_MANIFEST_FILENAME);
}
Expand All @@ -977,7 +979,7 @@ export const isDev = ${JSON.stringify(isDev)};
console.warn(
`\n==========\n` +
`Could not read Qwik client manifest ${clientManifestPath}.\n` +
`Make sure you provide it to the SSR renderer via the \`manifest\` argument, or define it in \`globalThis.__QWIK_MANIFEST__\` before the server bundle is loaded, or embed it in the server bundle by replacing \`globalThis.__QWIK_MANIFEST__\`.\n` +
`Make sure you provide it to the qwikVite plugin via the \`manifestInput\` \`manifestInputPath\` arguments, or to the SSR renderer via the \`manifest\` argument, or define it in \`globalThis.__QWIK_MANIFEST__\` before the server bundle is loaded, or embed it in the server bundle by replacing \`globalThis.__QWIK_MANIFEST__\`.\n` +
`Without the manifest, the SSR renderer will not be able to generate event handlers.\n` +
`(${e})\n` +
`==========\n`
Expand Down Expand Up @@ -1249,6 +1251,7 @@ export interface QwikPluginOptions {
vendorRoots?: string[];
manifestOutput?: ((manifest: QwikManifest) => Promise<void> | void) | null;
manifestInput?: QwikManifest | null;
manifestInputPath?: string | null;
input?: string[] | string | { [entry: string]: string };
outDir?: string;
ssrOutDir?: string;
Expand Down
14 changes: 7 additions & 7 deletions packages/qwik/src/optimizer/src/plugins/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}): any {
experimental: qwikViteOpts.experimental,
input,
manifestInput: qwikViteOpts.ssr?.manifestInput,
manifestInputPath: qwikViteOpts.ssr?.manifestInputPath,
manifestOutput: qwikViteOpts.client?.manifestOutput,
};

Expand Down Expand Up @@ -284,21 +285,18 @@ export function qwikVite(qwikViteOpts: QwikVitePluginOptions = {}): any {
};

if (!qwikViteOpts.csr) {
const buildOutputDir =
target === 'client' && viteConfig.base
? path.join(opts.outDir, viteConfig.base)
: opts.outDir;

updatedViteConfig.build!.cssCodeSplit = false;
updatedViteConfig.build!.outDir = buildOutputDir;
if (opts.outDir) {
updatedViteConfig.build!.outDir = opts.outDir;
}
const origOnwarn = updatedViteConfig.build!.rollupOptions?.onwarn;
updatedViteConfig.build!.rollupOptions = {
...updatedViteConfig.build!.rollupOptions,
output: await normalizeRollupOutputOptions(
qwikPlugin,
viteConfig.build?.rollupOptions?.output,
useAssetsDir,
buildOutputDir
opts.outDir
),
preserveEntrySignatures: 'exports-only',
onwarn: (warning, warn) => {
Expand Down Expand Up @@ -915,6 +913,8 @@ interface QwikVitePluginSSROptions extends QwikVitePluginCommonOptions {
* Default `undefined`
*/
manifestInput?: QwikManifest;
/** Same as `manifestInput` but allows passing the path to the file. */
manifestInputPath?: string;
};
}

Expand Down
1 change: 1 addition & 0 deletions starters/dev-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export {
optimizer.qwikVite({
entryStrategy: { type: "segment" },
client: {
outDir: join(appDistDir, appName),
manifestOutput(manifest) {
clientManifest = manifest;
},
Expand Down