Cannot turn off colormin optimization from the cssnano configuration

650 Views Asked by At

I have the Webpack setup in which I use optimize-css-assets-webpack-plugin with cssnano as the CSS processor.

In there, I don't want to use the colormin optimization.

Optimizations: https://cssnano.co/guides/optimisations

This is my current configuration which doesn't stop converting HSL value to hex:

plugins.push(new OptimizeCssAssetsPlugin({
  assetNameRegExp: /\.css$/g,
  cssProcessor: require('cssnano'),
  cssProcessorPluginOptions: {
    preset: ['default', {
      discardComments: {
        removeAll: true,
      },
      colormin: false,
    }],
  },
  canPrint: true,
}));

I need to know whats wrong with this configuration.

1

There are 1 best solutions below

0
On

Check the version of your optimize-css-assets-webpack-plugin and webpack. The last version of optimize-css-assets-webpack-plugin to support webpack 3 is version 3.2.0. And that version is configured differently:

plugins.push(new OptimizeCssAssetsPlugin({
  assetNameRegExp: /\.css$/g,
  cssProcessor: require('cssnano'),
  cssProcessorOptions: {
    discardComments: {
      removeAll: true,
    },
    colormin: false,
  },
  canPrint: true,
}));