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

vite preview can't use --mode option #17410

Closed
7 tasks done
Crone1331 opened this issue Jun 7, 2024 · 4 comments
Closed
7 tasks done

vite preview can't use --mode option #17410

Crone1331 opened this issue Jun 7, 2024 · 4 comments

Comments

@Crone1331
Copy link

Crone1331 commented Jun 7, 2024

Describe the bug

When I use vite preview -h,

vite/5.2.12

Usage:
  $ vite preview [root]

Options:
  --host [host]           [string] specify hostname 
  --port <port>           [number] specify port 
  --strictPort            [boolean] exit if specified port is already in use 
  --open [path]           [boolean | string] open browser on startup 
  --outDir <dir>          [string] output directory (default: dist) 
  -c, --config <file>     [string] use specified config file 
  --base <path>           [string] public base path (default: /) 
  -l, --logLevel <level>  [string] info | warn | error | silent 
  --clearScreen           [boolean] allow/disable clear screen when logging 
  -d, --debug [feat]      [string | boolean] show debug logs 
  -f, --filter <filter>   [string] filter debug logs 
  -m, --mode <mode>       [string] set env mode 
  -h, --help              Display this message 

But the vite preview command doesn't use the mode option.
A similar problem was solved here, but apparently without success:

#6391

Reproduction

any project

Steps to reproduce

any project

System Info

System:
    OS: Linux 5.15 Ubuntu 20.04.6 LTS (Focal Fossa)
    CPU: (4) x64 Intel(R) Core(TM) i3-9100 CPU @ 3.60GHz
    Memory: 23.49 GB / 31.22 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
    npm: 10.5.0 - ~/.nvm/versions/node/v20.12.2/bin/npm
  Browsers:
    Chrome: 125.0.6422.141
  npmPackages:
    @vitejs/plugin-vue: ^5.0.4 => 5.0.5 
    vite: ^5.2.0 => 5.2.12

Used Package Manager

npm

Logs

No response

Validations

@bluwy
Copy link
Member

bluwy commented Jun 10, 2024

It is passed here

mode: options.mode,
. Can you provide a repro?

Copy link

Hello @Crone1331. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs reproduction will be closed if they have no activity within 3 days.

@Shakeskeyboarde
Copy link
Contributor

Shakeskeyboarde commented Jun 12, 2024

Preview doesn't actually build. So, while the mode option is supported for preview, it realistically is only there for completeness. The configuration file is loaded for preview, but only for the preview configuration, which could theoretically depend on the mode passed to the preview command. Any other configuration which is unrelated to the preview server, will be effectively ignored.

@Shakeskeyboarde
Copy link
Contributor

I wrote a tool which may behave a little more like you expect. It puts together vite build with watching and a preview server as a single command.

Hope this helps. Feel free to post issues on the repo or contribute.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 16, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jul 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants