I am trying to configure cssnano
plugin for the postcss-loader
, which minifies CSS, very similar, as described here.
Webpack config:
...
module: {
rules: [
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
{
loader: 'postcss-loader',
options: {
ident: 'postcss',
plugins: () => [
cssnano({
preset: ['default', {
discardComments: {
removeAll: true,
},
// how to find index of all available options?
}]
})
]
}
},
'sass-loader'
]
}
]
},
...
Here are listed all the optimisations from cssnano documentation
And here is an example of how to override a single optimisation discardComments
on top of default
preset.
Is it possible to override each optimisation configuration individually, like with discardComments
? This could be very handy in creating a separate configurations for dev and production.
Also, in this repo is an unsuccessful attempt with minimal example and the boilerplate.
EDIT: cssnano devs told it is not possible to configure each optimisation individually, instead, it might be possible to use each optimisation plugin separately source