All Projects → aymericbeaumet → metalsmith-clean-css

aymericbeaumet / metalsmith-clean-css

Licence: MIT license
🚿 Metalsmith plugin to minify CSS files

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to metalsmith-clean-css

markdown
A metalsmith plugin to render markdown files to HTML.
Stars: ✭ 58 (+205.26%)
Mutual labels:  metalsmith-plugin
metalsmith-tags
A metalsmith plugin to create dedicated pages for tags in posts or pages.
Stars: ✭ 48 (+152.63%)
Mutual labels:  metalsmith-plugin
remove
A Metalsmith plugin to remove files from the build
Stars: ✭ 19 (+0%)
Mutual labels:  metalsmith-plugin
metalsmith-redirect
🚏 Metalsmith plugin to create HTTP redirections
Stars: ✭ 27 (+42.11%)
Mutual labels:  metalsmith-plugin
metalsmith-concat
📎 Metalsmith plugin to concatenate files
Stars: ✭ 16 (-15.79%)
Mutual labels:  metalsmith-plugin
headings
A Metalsmith plugin that extracts headings from HTML files and attaches them to the file's metadata.
Stars: ✭ 22 (+15.79%)
Mutual labels:  metalsmith-plugin
permalinks
A Metalsmith plugin for permalinks.
Stars: ✭ 61 (+221.05%)
Mutual labels:  metalsmith-plugin

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].