Home

Awesome

metalsmith-clean-css

travis github npm

This plugin allows you to minify your CSS files by leveraging clean-css.

Install

npm install metalsmith-clean-css clean-css

Usage

CLI

metalsmith.json

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

Node.js

const metalsmith = require('metalsmith')
const metalsmithCleanCSS = require('metalsmith-clean-css')

metalsmith(__dirname).use(
  metalsmithCleanCSS({
    files: 'src/**/*.css',
    cleanCSS: {
      rebase: true,
    },
  })
)

API

metalsmithCleanCSS(options)

options

Type: Object Default: {}

options.cleanCSS

Type: Object Default: {}

Allow you to directly manipulate the clean-css API. The configuration object will be passed as is.

options.files

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.

options.sourceMap

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.

options.sourceMapInlineSources

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.