babel-plugin-lodash webpack配置未执行任何操作

时间:2019-12-20 19:51:38

标签: javascript webpack lodash babeljs

我是babel / webpack新手,我受命减小Lodash捆绑包的大小。我或多或少了解了如何插入简单的插件和更改,但是无论出于何种原因,babel-plugin-lodash的响应方式都不相同lodash-webpack-plugin。我觉得我只是一个小失误,无法按预期工作。

我正在使用Babel 7+版本和Webpack 4+版本

在webpack.config.js中

    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: {
          loader: 'babel-loader',
          query: {
            presets: [
              ["@babel/preset-env", { 
                "targets": { "node": 6 },
              }],
              "@babel/preset-react"
            ],
            plugins: [  
              ['styled-components', { displayName: true } ],
              'lodash'
            ]
          }
        }
      },

在.babelrc中

{
  "presets": [
    ["@babel/preset-env", { "targets": { "node": 6 } }],
    "@babel/preset-react"
  ],
  "plugins": [
    "lodash",
    "transform-class-properties",
    ["styled-components", { "displayName": true }],
    "@babel/plugin-proposal-object-rest-spread",
    [ "@babel/transform-runtime", { "regenerator": true }],

  ]

}

Webpack Analyzer Result

0 个答案:

没有答案