Invalid webpack4 tree-shaking

webpack4 tree-shaking, I configure mode according to the official documentation, setting mode to production, but not optimizing my code. My app.js only introduces the a () method of util.js, but when packaging, other methods of util are also packaged, asking for advice,

Mar.13,2021

change modules to false in the js configuration parameter of the configuration file, options: {preset: [['babel-preset-env'], {modules:false}]}


Hello, have you solved this problem? Encountered the same problem

officially configure ides/tree-shaking/" rel=" nofollow noreferrer "> https://www.webpackjs.com/gui.

as follows

I have the same problem. Can you explain in more detail upstairs? I can't find a place.


you may have used OptimizeCSSAssetsPlugin, then add TerserPlugin. The code is as follows:

const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
...

optimization: {
    minimizer: [
      new OptimizeCSSAssetsPlugin(),
      new TerserPlugin()
    ]
  }

then tree shaking will take effect. Of course, it is also effective to empty, tree shaking of all plug-ins in minimizer.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3a13f-2c1df.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3a13f-2c1df.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?