diff --git a/src/utils/example-webcontainer-start.ts b/src/utils/example-webcontainer-start.ts index f2edf5987..efb705388 100644 --- a/src/utils/example-webcontainer-start.ts +++ b/src/utils/example-webcontainer-start.ts @@ -129,7 +129,8 @@ export function getWebContainerStartCommand(runtime: ExampleRuntime) { } const args = [...runtime.start.args] - if (!args.includes('--')) args.push('--') + // npm needs `--` to forward args. pnpm would pass the `--` itself on to Vite, which ignores what follows. + if (runtime.start.command === 'npm' && !args.includes('--')) args.push('--') args.push('--config', tanStackStartViteConfigPath.slice(1)) return { command: runtime.start.command, args } diff --git a/tests/example-webcontainer-start.test.ts b/tests/example-webcontainer-start.test.ts index 0a683da7f..f53c0bf53 100644 --- a/tests/example-webcontainer-start.test.ts +++ b/tests/example-webcontainer-start.test.ts @@ -99,8 +99,18 @@ describe('TanStack Start WebContainer compatibility', () => { test('starts Vite with the hidden config only for the Start profile', () => { assert.deepEqual(getWebContainerStartCommand(startRuntime), { command: 'pnpm', - args: ['run', 'dev', '--', '--config', '.tanstack/vite.config.mjs'], + args: ['run', 'dev', '--config', '.tanstack/vite.config.mjs'], }) + assert.deepEqual( + getWebContainerStartCommand({ + ...startRuntime, + start: { command: 'npm', args: ['run', 'dev'] }, + }), + { + command: 'npm', + args: ['run', 'dev', '--', '--config', '.tanstack/vite.config.mjs'], + }, + ) assert.deepEqual( getWebContainerStartCommand({