如何从prod build Angular中的ngx-build-plus中排除Devextreme?

时间:2019-08-26 07:03:18

标签: angular webpack devextreme devextreme-angular

我一直在角度应用中使用devextreme,但同时使prod build的尺寸更大。因此,我想使用ngx-build-plus和webpack ignore插件将其从产品构建中排除,但不能排除。

  1. 我尝试将ngx-build-plus与webpack.extras.js一起使用,但并不排除这种情况。

    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. 我尝试使用webpackignore插件将其排除,我看到错误与api方案不匹配。

      

    发生未处理的异常:无效的配置对象。已使用与API模式不匹配的配置对象初始化Webpack。 -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。请让我知道是否有解决方案。

1 个答案:

答案 0 :(得分:0)

您将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/)
  ]
}