【问题标题】:Excluding static JS files for compilation with Babel + webpack使用 Babel + webpack 排除静态 JS 文件进行编译
【发布时间】:2018-03-13 07:51:40
【问题描述】:

我在我的新项目中使用 webpackBabel。在添加静态 JS 文件之前,一切都很好。通常捆绑操作需要 5 秒。但添加OpenLayers 库捆绑后大约需要420 秒!!! OpenLayers JS 文件大小约为 490 KB,它是 uglified。所以不需要编译。

我没有使用 Babel 只用 webpack 进行了测试,耗时 5 秒。所以问题在于 Babel 编译。如何防止 Babel 不编译 OpenLayers 并将其添加到结果包文件中。我也可以使用其他外部 JS 文件以及 OpenLayers。

【问题讨论】:

    标签: webpack ecmascript-6 bundle openlayers-3 babeljs


    【解决方案1】:

    你可以排除它:

    {
      // ...
      loader: 'babel-loader',
      exclude: /node_modules/ // exclude all package you install
    }
    

    您可以在https://webpack.js.org/configuration/module/#rule-exclude阅读更多相关信息

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-06-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多