How does webpack4 package remove console?

use

new webpack.optimize.UglifyJsPlugin({
     compress: {
         warnings: false,
         drop_debugger: true,
         drop_console: true
     }
)}

prompt that the method has been removed. It is recommended that you use minimize,minimize to remove console.

Mar.29,2022


optimization: {
        minimizer: [
            new TerserPlugin({
                minify: (file, sourceMap) => {
                    // https://github.com/mishoo/UglifyJS2-sharpminify-options
                    const uglifyJsOptions = {
                        /* your `uglify-js` package options */
                        compress:{
                            drop_console:true
                        }
                    };

                    if (sourceMap) {
                        uglifyJsOptions.sourceMap = {
                            content: sourceMap,
                        };
                    }

                    return require('uglify-js').minify(file, uglifyJsOptions);
                },
            }),
        ],
    },

https://webpack.js.org/config...


use the cssnano plug-in
npm I-D @ intervolga/optimize-cssnano-plugin


const optimizeCssnanoPlugin = require('@intervolga/optimize-cssnano-plugin');


module.exports = {
    plugins: [
        new optimizeCssnanoPlugin({
            cssnanoOptions: {
                preset: [
                    'default',
                    {
                        discardComments: {
                            removeAll: true,
                        },
                    }
                ],
            },
        })
    ]
};
< hr >

read the wrong question, this is compressed css, the subject ignore it.

Menu