cssnano 2.3.0 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,24 @@
1
+ # 2.6.1
2
+
3
+ * Improved performance of the core module `functionOptimiser`.
4
+
5
+ # 2.6.0
6
+
7
+ * Adds a new optimisation which re-orders properties that accept values in
8
+ an arbitrary order. This can lead to improved merging behaviour in certain
9
+ cases.
10
+
11
+ # 2.5.0
12
+
13
+ * Adds support for disabling modules of the user's choosing, with new option
14
+ names. The old options (such as `merge` & `fonts`) will be removed in `3.0`.
15
+
16
+ # 2.4.0
17
+
18
+ * postcss-minify-selectors was extended to add support for conversion of
19
+ `::before` to `:before`; this release removes the dedicated
20
+ postcss-pseudoelements module.
21
+
1
22
  # 2.3.0
2
23
 
3
24
  * Consolidated postcss-minify-trbl & two integrated modules into
package/bin/usage.txt CHANGED
@@ -4,19 +4,18 @@ Options:
4
4
 
5
5
  --sourcemap, -s Generate a sourcemap within the minified output.
6
6
 
7
- --no-autoprefixer Disable removal of old vendor prefixed properties.
8
-
9
- --no-zindex Disable z-index transforms.
10
-
11
- --no-calc Disable calc transforms.
12
-
13
- --no-urls Disable URL normalisation.
14
-
15
- --no-idents Disable custom identifier reduction.
16
-
17
- --no-merge Disable merging of rules.
18
-
19
- --no-unused Disable unused at-rule removal.
7
+ --no-[featureName] Disable any individual processor module by its name.
8
+ [featureName] can be any one of these:
9
+
10
+ autoprefixer filterOptimiser normalizeUrl
11
+ calc filterPlugins orderedValues
12
+ colormin fontFamily reduceIdents
13
+ convertValues functionOptimiser singleCharset
14
+ core mergeIdents styleCache
15
+ discardComments mergeLonghand uniqueSelectors
16
+ discardDuplicates mergeRules zindex
17
+ discardEmpty minifyFontWeight
18
+ discardUnused minifySelectors
20
19
 
21
20
  --version, -v Outputs the version number.
22
21
 
package/index.js CHANGED
@@ -1,37 +1,40 @@
1
1
  'use strict';
2
2
 
3
+ var decamelize = require('decamelize');
4
+ var defined = require('defined');
3
5
  var postcss = require('postcss');
6
+ var warnOnce = require('./lib/warnOnce');
4
7
 
5
8
  var processors = {
6
- pluginFilter: function () {
9
+ postcssFilterPlugins: function () {
7
10
  return require('postcss-filter-plugins')({silent: true});
8
11
  },
9
- discardComments: {fn: require('postcss-discard-comments'), ns: 'comments'},
10
- autoprefixer: {fn: require('autoprefixer-core'), ns: 'autoprefixer'},
11
- zindex: {fn: require('postcss-zindex'), ns: 'zindex'},
12
- minifyFontWeight: require('postcss-minify-font-weight'),
13
- convertValues: require('postcss-convert-values'),
14
- calc: {fn: require('postcss-calc'), ns: 'calc'},
15
- colormin: require('postcss-colormin'),
16
- pseudoelements: require('postcss-pseudoelements'),
12
+ postcssDiscardComments: {fn: require('postcss-discard-comments'), ns: 'comments'},
13
+ autoprefixer: require('autoprefixer-core'),
14
+ postcssZindex: {fn: require('postcss-zindex')},
15
+ postcssMinifyFontWeight: require('postcss-minify-font-weight'),
16
+ postcssConvertValues: require('postcss-convert-values'),
17
+ postcssCalc: {fn: require('postcss-calc')},
18
+ postcssColormin: require('postcss-colormin'),
19
+ postcssOrderedValues: require('postcss-ordered-values'),
17
20
  filterOptimiser: require('./lib/filterOptimiser'),
18
- minifySelectors: require('postcss-minify-selectors'),
19
- singleCharset: require('postcss-single-charset'),
21
+ postcssMinifySelectors: require('postcss-minify-selectors'),
22
+ postcssSingleCharset: require('postcss-single-charset'),
20
23
  // font-family should be run before discard-unused
21
- fontFamily: {fn: require('postcss-font-family'), ns: 'fonts'},
22
- discardUnused: {fn: require('postcss-discard-unused'), ns: 'unused'},
23
- normalizeUrl: {fn: require('postcss-normalize-url'), ns: 'urls'},
24
+ postcssFontFamily: {fn: require('postcss-font-family'), ns: 'fonts'},
25
+ postcssDiscardUnused: {fn: require('postcss-discard-unused'), ns: 'unused'},
26
+ postcssNormalizeUrl: {fn: require('postcss-normalize-url'), ns: 'urls'},
24
27
  core: require('./lib/core'),
25
28
  // Optimisations after this are sensitive to previous optimisations in
26
29
  // the pipe, such as whitespace normalising/selector re-ordering
27
- mergeIdents: {fn: require('postcss-merge-idents'), ns: 'idents'},
28
- reduceIdents: {fn: require('postcss-reduce-idents'), ns: 'idents'},
29
- mergeLonghand: require('postcss-merge-longhand'),
30
- discardDuplicates: require('postcss-discard-duplicates'),
30
+ postcssMergeIdents: {fn: require('postcss-merge-idents'), ns: 'idents'},
31
+ postcssReduceIdents: {fn: require('postcss-reduce-idents'), ns: 'idents'},
32
+ postcssMergeLonghand: require('postcss-merge-longhand'),
33
+ postcssDiscardDuplicates: require('postcss-discard-duplicates'),
31
34
  functionOptimiser: require('./lib/functionOptimiser'),
32
- mergeRules: {fn: require('postcss-merge-rules'), ns: 'merge'},
33
- discardEmpty: require('postcss-discard-empty'),
34
- uniqueSelectors: require('postcss-unique-selectors'),
35
+ postcssMergeRules: {fn: require('postcss-merge-rules'), ns: 'merge'},
36
+ postcssDiscardEmpty: require('postcss-discard-empty'),
37
+ postcssUniqueSelectors: require('postcss-unique-selectors'),
35
38
  styleCache: require('./lib/styleCache')
36
39
  };
37
40
 
@@ -46,19 +49,35 @@ var cssnano = postcss.plugin('cssnano', function (options) {
46
49
  while (i < len) {
47
50
  var plugin = plugins[i++];
48
51
  var processor = processors[plugin];
49
- var opts = options[processor.ns] || options;
50
- var method;
51
- if (typeof processor === 'function') {
52
- method = processor;
53
- } else {
54
- if (opts[processor.ns] === false || opts.disable) {
55
- continue;
56
- }
57
- if (plugin === 'autoprefixer') {
58
- opts.add = false;
52
+ var method = processor;
53
+
54
+ var shortName = plugin.replace('postcss', '');
55
+ shortName = shortName.slice(0, 1).toLowerCase() + shortName.slice(1);
56
+
57
+ if (typeof processor !== 'function') {
58
+ if (typeof options[processor.ns] !== 'undefined') {
59
+ warnOnce('The ' + processor.ns + ' option is deprecated. ' +
60
+ 'Please use options.' + shortName + ' instead.');
61
+ options[plugin] = options[processor.ns];
59
62
  }
60
63
  method = processor.fn;
61
64
  }
65
+
66
+ var opts = defined(
67
+ options[shortName],
68
+ options[plugin],
69
+ options[decamelize(plugin, '-')],
70
+ {}
71
+ );
72
+
73
+ if (opts === false || opts.disable) {
74
+ continue;
75
+ }
76
+
77
+ if (plugin === 'autoprefixer') {
78
+ opts.add = false;
79
+ }
80
+
62
81
  proc.use(method(opts));
63
82
  }
64
83
 
@@ -9,9 +9,7 @@ var functions = [
9
9
  'calc',
10
10
  'cubic-bezier',
11
11
  'gradient',
12
- 'hsl',
13
12
  'rect',
14
- 'rgb',
15
13
  'rotate3d',
16
14
  'scale',
17
15
  'scale3d',
@@ -44,8 +42,6 @@ function optimise (decl) {
44
42
 
45
43
  module.exports = postcss.plugin('cssnano-function-optimiser', function () {
46
44
  return function (css) {
47
- functions.forEach(function (fn) {
48
- css.eachDecl(optimise);
49
- });
45
+ css.eachDecl(optimise);
50
46
  };
51
47
  });
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ var messages = {};
4
+
5
+ module.exports = function warnOnce (message) {
6
+ if (messages[message]) { return; }
7
+ messages[message] = true;
8
+ if (typeof console !== 'undefined' && console.warn) {
9
+ console.warn(message);
10
+ }
11
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cssnano",
3
- "version": "2.3.0",
3
+ "version": "2.6.1",
4
4
  "description": "A modular minifier, built on top of the PostCSS ecosystem.",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -29,7 +29,8 @@
29
29
  "autoprefixer-core": "^5.2.1",
30
30
  "balanced-match": "^0.2.0",
31
31
  "css-list": "^0.1.2",
32
- "flatten": "0.0.1",
32
+ "decamelize": "^1.0.0",
33
+ "defined": "^1.0.0",
33
34
  "indexes-of": "^1.0.1",
34
35
  "minimist": "^1.1.3",
35
36
  "postcss": "^4.1.16",
@@ -43,12 +44,12 @@
43
44
  "postcss-filter-plugins": "^1.0.0",
44
45
  "postcss-font-family": "^1.2.1",
45
46
  "postcss-merge-idents": "^1.0.1",
46
- "postcss-merge-longhand": "^1.0.0",
47
- "postcss-merge-rules": "^1.3.4",
47
+ "postcss-merge-longhand": "^1.0.1",
48
+ "postcss-merge-rules": "^1.3.5",
48
49
  "postcss-minify-font-weight": "^1.0.1",
49
- "postcss-minify-selectors": "^1.4.6",
50
+ "postcss-minify-selectors": "^1.5.0",
50
51
  "postcss-normalize-url": "^2.1.1",
51
- "postcss-pseudoelements": "^2.2.0",
52
+ "postcss-ordered-values": "^1.0.1",
52
53
  "postcss-reduce-idents": "^1.0.2",
53
54
  "postcss-single-charset": "^0.3.0",
54
55
  "postcss-unique-selectors": "^1.0.0",
@@ -61,7 +62,7 @@
61
62
  "json-loader": "^0.5.2",
62
63
  "node-libs-browser": "^0.5.2",
63
64
  "tap-spec": "^4.0.2",
64
- "tape": "^4.1.0",
65
+ "tape": "^4.2.0",
65
66
  "webpack": "^1.11.0"
66
67
  },
67
68
  "homepage": "https://github.com/ben-eb/cssnano",