🚿 Metalsmith plugin to minify CSS files
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.


NPM version Linux build status Windows build status Code coverage GPA Dependencies status


A Metalsmith plugin to minify CSS files.

Table of Contents generated with DocToc


npm install metalsmith-clean-css clean-css
# yarn add metalsmith-clean-css clean-css

metalsmith-clean-css is compatible with clean-css@4.1.9 and later versions.


This plugin relies on clean-css.

Metalsmith CLI

  "plugins": {
    "metalsmith-clean-css": {
      "files": "src/**/*.css"

JavaScript API

var MetalSmith = require('metalsmith');
var cleanCSS = require('metalsmith-clean-css');

    files: 'src/**/*.css',
    cleanCSS: {
      rebase: true


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.


  • 5.0.1

    • Bump dependencies
  • 5.0.0

    • Expect and produce a Buffer for the contents key (breaking)
  • 4.0.0

    • Only supports Node 4+
    • Bump clean-css@3.4.11
    • Support input source maps as file.sourceMap, ${filepath}.map and inline
    • Support to generate source maps as file.sourceMap and ${filepath}.map
  • 3.0.2

    • Switch test suite to nyc + ava
  • 3.0.1

    • Update options parsing
  • 3.0.0

    • Add AppVeyor
    • Add EditorConfig
    • Change license
    • Switch to standard coding style
    • 100% code coverage
    • Fix dependencies with shrinkwrap
    • Bump dependencies
    • Switch test engine to tape
  • 2.0.0

    • Update clean-css
  • 1.0.0

    • Bump stable
  • 0.0.3

    • Fix an issue with file content
  • 0.0.2

    • Fix the example
  • 0.0.1

    • Working plugin



To the extent possible under law, Aymeric Beaumet has waived all copyright and related or neighboring rights to this work.


nvm use
yarn test
# yarn test:watch


# commit changes
npm run release