How to include or exclude files from the compression process?
I'm using the ImageMinimizerPlugin together with the CopyPlugin as follows:
ImageMinimizerPlugin configuration:
const imgMinParams = {
include: PATHS.src + '/assets/images/include/these/files/',
generator: [
{
type: 'asset',
preset: 'webp',
implementation: ImageMinimizerPlugin.sharpGenerate,
options: {
encodeOptions: {
webp: {
quality: 6,
},
},
},
},
],
};
Optimization:
optimization: {
minimize: true,
minimizer: [
...
new ImageMinimizerPlugin(imgMinParams),
],
},
Copyplugin configuration:
const copyPluginParams = {
patterns: [
{
from: PATHS.src + '/assets/images/include/these/files/*.*',
to: PATHS.src + '/assets/images/compressed/[name].webp',
},
{
from: PATHS.src + '/assets/images/do/not/include/these/fi/*.*',
to: PATHS.src + '/assets/images/uncompressed/[name][ext]',
},
]
Plugins:
plugins: [
...
new CopyPlugin(copyPluginParams),
],