【问题标题】:How to Exclude Devextreme from ngx-build-plus from prod build Angular?如何从 prod build Angular 的 ngx-build-plus 中排除 Devextreme?
【发布时间】:2019-08-26 16:59:55
【问题描述】:

我一直在 Angular 应用程序中使用 devextreme,但在制作 prod build 时,它占用了更大的尺寸。所以,我想使用 ngx-build-plus 和 webpack 忽略插件将它从 prod 构建中排除,但它不排除。

  1. 我尝试使用带有 webpack.extras.js 的 ngx-build-plus,它不排除。

    module.exports = {
      "externals": {
        "rxjs": "rxjs",
        "@angular/core": "ng.core",
        "@angular/common": "ng.common",
        "@angular/platform-browser": "ng.platformBrowser",
        "devextreme" : "devextreme",
        "devexpress-diagram": "devexpress-diagram",
        "devextreme-schematics": "devextreme-schematics",
        "devextreme-angular": "devextreme-angular",
      }
    }
    
  2. 我尝试使用 webpack 忽略插件来排除它,我看到错误与 api 方案不匹配。

    发生未处理的异常:配置对象无效。 Webpack 已使用与 API 模式不匹配的配置对象进行初始化。 - configuration.externals['plugins'][0] 应该是一个字符串。

    module.exports = {
      "externals": {
        "rxjs": "rxjs",
        "@angular/core": "ng.core",
        "@angular/common": "ng.common",
        "@angular/platform-browser": "ng.platformBrowser",
        "plugins":[
          new webpack.IgnorePlugin(/devextreme/)
        ]
      }
    }
    

它应该从 prod 构建中排除 devextreme。如果有任何解决方案,请告诉我。

【问题讨论】:

    标签: angular webpack devextreme devextreme-angular


    【解决方案1】:

    您将plugins 配置对象放在externals 配置对象中。应该是:

    module.exports = {
      "externals": {
        "rxjs": "rxjs",
        "@angular/core": "ng.core",
        "@angular/common": "ng.common",
        "@angular/platform-browser": "ng.platformBrowser"
      },
      "plugins":[
        new webpack.IgnorePlugin(/devextreme/)
      ]
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-28
      • 2019-07-26
      • 1970-01-01
      • 2019-05-25
      相关资源
      最近更新 更多