Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isPreview is always false #15694

Closed
7 tasks done
hyunbinseo opened this issue Jan 23, 2024 · 2 comments · Fixed by #15695
Closed
7 tasks done

isPreview is always false #15694

hyunbinseo opened this issue Jan 23, 2024 · 2 comments · Fixed by #15695
Labels
contribution welcome p4-important Violate documented behavior or significantly improves performance (priority)

Comments

@hyunbinseo
Copy link
Contributor

Describe the bug

Both vite dev and vite preview passes isPreview: false.

It was implemented to distinguish these two, and it seems to be broken.

import { defineConfig } from 'vite';

export default defineConfig((config) => {
  console.log(config);
  return {};
});
# npm run dev
{
  mode: 'development',
  command: 'serve',
  isSsrBuild: false,
  isPreview: false
}
# npm run preview
{
  mode: 'production',
  command: 'serve',
  isSsrBuild: false,
  isPreview: false
}

Reproduction

https://stackblitz.com/edit/vitejs-vite-qgb5dt?file=vite.config.js

Steps to reproduce

No response

System Info

System:
  OS: Linux 5.0 undefined
  CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  Memory: 0 Bytes / 0 Bytes
  Shell: 1.0 - /bin/jsh
Binaries:
  Node: 18.18.0 - /usr/local/bin/node
  Yarn: 1.22.19 - /usr/local/bin/yarn
  npm: 10.2.3 - /usr/local/bin/npm
  pnpm: 8.14.0 - /usr/local/bin/pnpm
npmPackages:
  vite: ^5.0.11 => 5.0.12

Used Package Manager

npm

Logs

No response

Validations

Copy link

stackblitz bot commented Jan 23, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@bluwy
Copy link
Member

bluwy commented Jan 23, 2024

Looks like I forgot to pass the isPreview param here 🤦 (5th param of resolveConfig)

export async function preview(
inlineConfig: InlineConfig = {},
): Promise<PreviewServer> {
const config = await resolveConfig(
inlineConfig,
'serve',
'production',
'production',
)

Feel free to send a PR!

@bluwy bluwy added p4-important Violate documented behavior or significantly improves performance (priority) contribution welcome and removed pending triage labels Jan 23, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Feb 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
contribution welcome p4-important Violate documented behavior or significantly improves performance (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants