WebPack Babel 忽略 node_modules 有例外

WebPack Babel ignore node_modules with exceptions

我有一个用 ES6 编写的 node_module,所以在 IE11 中查看时会出现问题。为了解决这个问题,我设置了 babel 这样就解决了 IE11 的问题。但是,babel 似乎试图解析所有节点模块,而不仅仅是我想要的那个。如何正确排除所有节点模块 bar flv.js?请注意,我从 github thread

中找到了排除语法
{
    test: /\.jsx?$/,
    exclude:/node_modules\/(?!flv.js)/,
    loader: 'babel-loader',
    query: {
        presets: ['es2015']
    }
},

WebPack 输出让我觉得它的转译不仅仅是 flv.js

[BABEL] Note: The code generator has deoptimised the styling of "C:/TFS/.../node_modules/lodash/lodash.js" as it exceeds the max of "500KB".

[BABEL] Note: The code generator has deoptimised the styling of "C:/TFS/.../node_modules/angular-google-maps/dist/angular-google-maps.js" as it exceeds the max of "500KB".

[BABEL] Note: The code generator has deoptimised the styling of "C:/TFS/.../node_modules/angular/angular.js" as it exceeds the max of "500KB".

[BABEL] Note: The code generator has deoptimised the styling of "C:/TFS/...b/node_modules/angular-material/angular-material.js" as it exceeds the max of "500KB".

我设法解决了这个问题,但我设法解决的唯一方法是使用 babel 转译节点模块,就像这样 (WebPack 3)。注意速度,我忽略所有节点模块,禁止有问题的模块 (flv.js)

{
    test: /\.jsx?$/,
    exclude: /node_modules\/(?!flv.js)/,
    loader: 'babel-loader',
    query: {
        presets: ['es2015'],
        compact: true
    }
},

将以下内容添加到 package.json

"babel-core": "6.23.0",
"babel-loader": "7.1.4",
"babel-preset-es2015": "6.24.1",
"babel-preset-env": "1.6.1",