【问题标题】:How svelte-kit build for staging env?如何为 staging env 构建 svelte-kit?
【发布时间】:2021-11-18 07:44:24
【问题描述】:

我想使用 svelte-kit 构建一个用于 staging 环境的 svelte 应用程序。我没有找到合适的命令来将.env.staging 作为其配置。

当我执行svelte-lit build 时,它总是需要.env.production

请帮助我了解如何构建临时环境。

【问题讨论】:

    标签: svelte sveltekit


    【解决方案1】:

    https://github.com/vitejs/vite/issues/512#issuecomment-656547187 - 检查这个答案(和主题),有一些解决方法。

    答案副本:

    "scripts": {
        "build:dev": "APP_ENV=development vite build",
        "build:prod": "APP_ENV=production vite build",
    }
    

    在你的 vite.config.js 中,现在你可以操作它了:

    const mode = process.env.APP_ENV // This now exists.
    
    module.exports = {
      mode: mode, // This will set the mode, to avoid confusions.
    }
    

    还有另一个 github 问题:https://github.com/sveltejs/kit/issues/1258

    【讨论】:

      猜你喜欢
      • 2021-11-20
      • 1970-01-01
      • 2022-01-20
      • 1970-01-01
      • 2021-12-29
      • 2023-01-08
      • 2021-12-25
      • 2022-01-13
      • 1970-01-01
      相关资源
      最近更新 更多