【问题标题】:ExpressJS - Using local files in development and files from Azure Blob Storage in productionExpressJS - 在开发中使用本地文件,在生产中使用来自 Azure Blob 存储的文件
【发布时间】:2015-03-21 07:49:12
【问题描述】:

我计划在 express 上重新构建一个应用程序,其中包含从 azure blob 存储中检索到的静态资产。在我的玉文件和 Sass 中切换引用的最简单方法是什么,以便在本地工作/开发时,express 查找本地资产,而在推送到生产环境时,它会从 azure 中查找资产?

我在构建过程中使用 Gulp,所以最好在构建中执行,还是直接在应用程序中作为方法?

【问题讨论】:

    标签: node.js azure express gulp azure-blob-storage


    【解决方案1】:

    出于此答案的目的,我假设两个环境(产品和测试/开发)都是 Linux。

    在运行您的 express 服务的环境中,您可以执行以下操作,这将允许 express 了解它在哪个环境中运行。这将在重新启动时保存状态。将“生产”替换为服务在该机器上运行的任何环境(开发/生产/测试/等)。

    $ echo export NODE_ENV=production >> ~\.bash_profile
    $ source ~/.bash_profile
    

    现在,在您的 app.js 文件中,您可以通过修改以下 sn-ps 来配置您的应用程序引用:

    app.configure('development', function() {
        // Set an application variable to use local resources
    });
    
    app.configure('production', function() {
        // Set an application variable to use Azure Blob Storage
    });
    

    【讨论】:

      猜你喜欢
      • 2019-04-04
      • 2020-02-14
      • 2021-08-31
      • 2015-09-11
      • 2022-01-12
      • 2021-05-09
      • 2012-05-20
      • 2019-09-21
      • 1970-01-01
      相关资源
      最近更新 更多