Comparing version
@@ -7,18 +7,16 @@ Usage: cssnano [input] [output] {OPTIONS} | ||
--no-autoprefixer Disable removal of old vendor prefixed properties. | ||
--no-[featureName] Disable any individual processor module by its name. | ||
[featureName] can be any one of these: | ||
--no-zindex Disable z-index transforms. | ||
autoprefixer discardUnused minifyFontWeight | ||
calc filterOptimiser minifySelectors | ||
colormin filterPlugins normalizeUrl | ||
convertValues fontFamily reduceIdents | ||
core functionOptimiser singleCharset | ||
discardComments mergeIdents styleCache | ||
discardDuplicates mergeLonghand uniqueSelectors | ||
discardEmpty mergeRules zindex | ||
--no-calc Disable calc transforms. | ||
--no-urls Disable URL normalisation. | ||
--no-idents Disable custom identifier reduction. | ||
--no-merge Disable merging of rules. | ||
--no-unused Disable unused at-rule removal. | ||
--version, -v Outputs the version number. | ||
--help, -h Outputs this help screen. |
@@ -0,1 +1,6 @@ | ||
# 2.5.0 | ||
* Adds support for disabling modules of the user's choosing, with new option | ||
names. The old options (such as `merge` & `fonts`) will be removed in `3.0`. | ||
# 2.4.0 | ||
@@ -2,0 +7,0 @@ |
79
index.js
'use strict'; | ||
var decamelize = require('decamelize'); | ||
var defined = require('defined'); | ||
var postcss = require('postcss'); | ||
var warnOnce = require('./lib/warnOnce'); | ||
var processors = { | ||
pluginFilter: function () { | ||
postcssFilterPlugins: function () { | ||
return require('postcss-filter-plugins')({silent: true}); | ||
}, | ||
discardComments: {fn: require('postcss-discard-comments'), ns: 'comments'}, | ||
autoprefixer: {fn: require('autoprefixer-core'), ns: 'autoprefixer'}, | ||
zindex: {fn: require('postcss-zindex'), ns: 'zindex'}, | ||
minifyFontWeight: require('postcss-minify-font-weight'), | ||
convertValues: require('postcss-convert-values'), | ||
calc: {fn: require('postcss-calc'), ns: 'calc'}, | ||
colormin: require('postcss-colormin'), | ||
postcssDiscardComments: {fn: require('postcss-discard-comments'), ns: 'comments'}, | ||
autoprefixer: require('autoprefixer-core'), | ||
postcssZindex: {fn: require('postcss-zindex')}, | ||
postcssMinifyFontWeight: require('postcss-minify-font-weight'), | ||
postcssConvertValues: require('postcss-convert-values'), | ||
postcssCalc: {fn: require('postcss-calc')}, | ||
postcssColormin: require('postcss-colormin'), | ||
filterOptimiser: require('./lib/filterOptimiser'), | ||
minifySelectors: require('postcss-minify-selectors'), | ||
singleCharset: require('postcss-single-charset'), | ||
postcssMinifySelectors: require('postcss-minify-selectors'), | ||
postcssSingleCharset: require('postcss-single-charset'), | ||
// font-family should be run before discard-unused | ||
fontFamily: {fn: require('postcss-font-family'), ns: 'fonts'}, | ||
discardUnused: {fn: require('postcss-discard-unused'), ns: 'unused'}, | ||
normalizeUrl: {fn: require('postcss-normalize-url'), ns: 'urls'}, | ||
postcssFontFamily: {fn: require('postcss-font-family'), ns: 'fonts'}, | ||
postcssDiscardUnused: {fn: require('postcss-discard-unused'), ns: 'unused'}, | ||
postcssNormalizeUrl: {fn: require('postcss-normalize-url'), ns: 'urls'}, | ||
core: require('./lib/core'), | ||
// Optimisations after this are sensitive to previous optimisations in | ||
// the pipe, such as whitespace normalising/selector re-ordering | ||
mergeIdents: {fn: require('postcss-merge-idents'), ns: 'idents'}, | ||
reduceIdents: {fn: require('postcss-reduce-idents'), ns: 'idents'}, | ||
mergeLonghand: require('postcss-merge-longhand'), | ||
discardDuplicates: require('postcss-discard-duplicates'), | ||
postcssMergeIdents: {fn: require('postcss-merge-idents'), ns: 'idents'}, | ||
postcssReduceIdents: {fn: require('postcss-reduce-idents'), ns: 'idents'}, | ||
postcssMergeLonghand: require('postcss-merge-longhand'), | ||
postcssDiscardDuplicates: require('postcss-discard-duplicates'), | ||
functionOptimiser: require('./lib/functionOptimiser'), | ||
mergeRules: {fn: require('postcss-merge-rules'), ns: 'merge'}, | ||
discardEmpty: require('postcss-discard-empty'), | ||
uniqueSelectors: require('postcss-unique-selectors'), | ||
postcssMergeRules: {fn: require('postcss-merge-rules'), ns: 'merge'}, | ||
postcssDiscardEmpty: require('postcss-discard-empty'), | ||
postcssUniqueSelectors: require('postcss-unique-selectors'), | ||
styleCache: require('./lib/styleCache') | ||
@@ -48,15 +51,31 @@ }; | ||
var processor = processors[plugin]; | ||
var opts = options[processor.ns] || options; | ||
var method; | ||
if (typeof processor === 'function') { | ||
method = processor; | ||
} else { | ||
if (opts[processor.ns] === false || opts.disable) { | ||
continue; | ||
var method = processor; | ||
var shortName = plugin.replace('postcss', ''); | ||
shortName = shortName.slice(0, 1).toLowerCase() + shortName.slice(1); | ||
if (typeof processor !== 'function') { | ||
if (typeof options[processor.ns] !== 'undefined') { | ||
warnOnce('The ' + processor.ns + ' option is deprecated. ' + | ||
'Please use options.' + shortName + ' instead.'); | ||
options[plugin] = options[processor.ns]; | ||
} | ||
if (plugin === 'autoprefixer') { | ||
opts.add = false; | ||
} | ||
method = processor.fn; | ||
} | ||
var opts = defined( | ||
options[shortName], | ||
options[plugin], | ||
options[decamelize(plugin, '-')], | ||
{} | ||
); | ||
if (opts === false || opts.disable) { | ||
continue; | ||
} | ||
if (plugin === 'autoprefixer') { | ||
opts.add = false; | ||
} | ||
proc.use(method(opts)); | ||
@@ -63,0 +82,0 @@ } |
{ | ||
"name": "cssnano", | ||
"version": "2.4.0", | ||
"version": "2.5.0", | ||
"description": "A modular minifier, built on top of the PostCSS ecosystem.", | ||
@@ -32,2 +32,4 @@ "main": "index.js", | ||
"css-list": "^0.1.2", | ||
"decamelize": "^1.0.0", | ||
"defined": "^1.0.0", | ||
"indexes-of": "^1.0.1", | ||
@@ -34,0 +36,0 @@ "minimist": "^1.1.3", |
19032
8.36%13
8.33%248
9.73%29
7.41%+ Added
+ Added
+ Added
+ Added