This plugin allows you to minify your CSS files by leveraging clean-css.
npm install metalsmith-clean-css clean-css
metalsmith.json
{
"plugins": {
"metalsmith-clean-css": {
"files": "**/*.css"
}
}
}
const metalsmith = require('metalsmith')
const metalsmithCleanCSS = require('metalsmith-clean-css')
metalsmith(__dirname).use(
metalsmithCleanCSS({
files: 'src/**/*.css',
cleanCSS: {
rebase: true,
},
})
)
Type: Object
Default: {}
Type: Object
Default: {}
Allow you to directly manipulate the clean-css API. The configuration object will be passed as is.
Type: string
Default: **/*.css
This option defines which files are concerned by the minification. This string is directly passed to minimatch. Each file matching the pattern will be minified in place using clean-css.
Type: boolean
Default: false
Whether the source maps should be kept after the minification. You can force
to inline the source maps (without creating an extra .map
file in the
build) by setting options.sourceMapInlineSources
to true
.
This plugin supports the forwarding of existing source maps, it will first
look for a sourceMap
property on the file, then for .map
file, and
finally fallback to inline source maps.
Type: boolean
Default: false
Whether the source maps should be inlined in each CSS file. If set to true
the source maps will be inlined in each file, and no extra .map
file will
be generated.