【问题标题】:Jhipster: how to override SERVER_API_URL for prod webpack profileJhipster:如何覆盖产品 webpack 配置文件的 SERVER_API_URL
【发布时间】:2018-05-15 23:21:54
【问题描述】:

我知道 SERVER_API_URL 是在 webpack-common.js 中定义的,默认情况下是空的。但在生产中,我需要不同的 api URL,我在 webpack-prod.js 的“plugins”数组中添加了以下内容,但没有看到任何效果。我相信它必须与 webpack-merge 相关,现在它可以与 DefinePlugin 一起使用。我试图阅读 webpack-merge 的文档,但看起来需要大量阅读。

        new webpack.DefinePlugin({
        'process.env': {
            // The root URL for API calls, ending with a '/' - for example: `"http://www.jhipster.tech:8081/myservice/"`.
            // If this URL is left empty (""), then it will be relative to the current context.
            // If you use an API server, in `prod` mode, you will need to enable CORS
            // (see the `jhipster.cors` common JHipster property in the `application-*.yml` configurations)
            SERVER_API_URL: '"http://172.26.0.150:9000/"'
        }
    })

该 url 仍在从 webpack-common.js 中获取,并且未被此设置覆盖。

【问题讨论】:

    标签: webpack jhipster webpack-2


    【解决方案1】:

    在这个 stackoverflow 问题中找到了解决方案:How to set the REST api address in Angular according to build?

    user2831852 的建议效果很好:

    SERVER_API_URL: options.env === 'development' ?开发主机:生产主机

    【讨论】:

      猜你喜欢
      • 2018-02-27
      • 2023-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-08
      • 2019-02-04
      • 2019-07-02
      • 2018-11-29
      相关资源
      最近更新 更多