Autopolyfiller-Loader: 专为 Webpack 设计的 Autopolyfiller 加载器

简介

Autopolyfiller-Loader 是一款用于 Webpack 的加载器,动态加载 JavaScript 应用程序所需的 polyfill。它会分析您的代码,识别出未被原生浏览器支持的特性,并仅应用必要的 polyfill。

安装

npm i -S autopolyfiller-loader

用法

module: {
  rules: [
    {
      enforce: 'post',
      test: /.js$/,
      exclude: //(node_modules|bower_components)//,
      loader: 'autopolyfiller-loader',
      query: {
        browsers: ['last 2 versions', 'ie >= 9'] // 要应用 polyfill 的浏览器列表
      }
    }
  ]
}
zip 文件大小:6.4KB