【问题标题】:How to set vite (preview) production port?如何设置 vite(预览版)生产端口?
【发布时间】:2022-01-23 12:37:05
【问题描述】:

我一直在寻找如何为 vite 设置生产端口,但我找不到方法 我试过这个 vite js 配置

  server: {
    host: true,
  },
  preview:{
    port:5005
  }

但是好像不行

【问题讨论】:

    标签: reactjs vue.js svelte vite


    【解决方案1】:

    根据documentation 这应该可以工作

    export default defineConfig({
      server: {
        port: 3030
      },
      preview: {
        port: 8080
      }
    })
    

    但如果它不起作用,请在 package.json 的预览命令中添加 --port

    "scripts": {
        "serve": "vite preview --port 6000"
      },
    

    【讨论】:

      猜你喜欢
      • 2018-07-09
      • 2020-02-24
      • 1970-01-01
      • 2021-11-17
      • 2011-07-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多