'image-minimizer-webpack-plugin generator keep originals

When i load an image in my webpack i want to optimize that image AND make a webp of that image. Im using image-minimizer-webpack-plugin with minimizer AND generator options, but it only generates the webp, the original version is deleted

 optimization: {
        minimize: true,
        minimizer: [
            "...",
            new ImageMinimizerPlugin({
                generator: [
                    {
                        preset: "webp",
                        implementation: ImageMinimizerPlugin.imageminGenerate,
                        options: {
                            plugins: ["imagemin-webp"],
                        },
                    },
                    {
                        type: "asset",
                        implementation: ImageMinimizerPlugin.imageminGenerate,
                        options: {
                            plugins: ["imagemin-webp"],
                        },
                    },
                ],
                minimizer: {
                    implementation: ImageMinimizerPlugin.imageminMinify,
                    options: {
                        plugins: [
                            ['gifsicle', { interlaced: true }],
                            ['jpegtran', { progressive: true }],
                            ['optipng', { optimizationLevel: 5 }],
                            [
                                'svgo',
                                {
                                    plugins: [
                                        {
                                            name: 'preset-default',
                                            params: {
                                                overrides: {
                                                    removeViewBox: false,
                                                },
                                            },
                                        },
                                    ],
                                },
                            ],
                        ],
                    },
                },
            }),
        ],
    },


Solution 1:[1]

 optimization: {
    minimize: true,
    minimizer: [
        "...",
        new ImageMinimizerPlugin({
            deleteOriginalAssets: false,
            generator: [
                {
                    type: "asset",
                    implementation: ImageMinimizerPlugin.imageminGenerate,
                    options: {
                        plugins: ["imagemin-webp"],
                    },
                    //If you just want to make webp of some images, you can use a filter
                    filter: (source, sourcePath) => {return true;},
                },
            ],
            minimizer: {
                implementation: ImageMinimizerPlugin.imageminMinify,
                options: {
                    plugins: [
                        ['gifsicle', { interlaced: true }],
                        ['jpegtran', { progressive: true }],
                        ['optipng', { optimizationLevel: 5 }],
                        [
                            'svgo',
                            {
                                plugins: [
                                    {
                                        name: 'preset-default',
                                        params: {
                                            overrides: {
                                                removeViewBox: false,
                                            },
                                        },
                                    },
                                ],
                            },
                        ],
                    ],
                },
            },
        }),
    ],
},

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 tenhill