0

我一直在 Angular 应用程序中使用 devextreme,但在制作 prod 构建时,它需要更大的尺寸。所以,我想使用 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 。请让我知道是否有任何解决方案。

4

1 回答 1

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/)
  ]
}
于 2019-08-26T07:20:45.983 回答