cssnano 3.9.1 → 3.10.0

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,16 @@
1
+ # 3.10.0
2
+
3
+ * cssnano will no longer `console.warn` any messages when using deprecated
4
+ options; these are now sent to PostCSS. You will be able to see them if you
5
+ use a PostCSS runner with built-in messages support, or alternately by
6
+ loading `postcss-reporter` or `postcss-browser-reporter` in your plugins list.
7
+ * Prepares support for `grid` identifier reduction by adding it to the list
8
+ of optimisations turned off when `options.safe` is set to `true`.
9
+ * Adds support for normalizing `unicode-range` descriptors. Values will
10
+ be converted when the code matches `0` & `f` in the same place on both sides
11
+ of the range. So, `u+2000-2fff` can be converted to `u+2???`, but
12
+ `u+2100-2fff` will be left as it is.
13
+
1
14
  # 3.9.1
2
15
 
3
16
  * Resolves an integration issue with `v3.9.0`, where `undefined` values
package/dist/index.js CHANGED
@@ -134,6 +134,10 @@ var _normalizeString = require('./lib/normalizeString');
134
134
 
135
135
  var _normalizeString2 = _interopRequireDefault(_normalizeString);
136
136
 
137
+ var _normalizeUnicode = require('./lib/normalizeUnicode');
138
+
139
+ var _normalizeUnicode2 = _interopRequireDefault(_normalizeUnicode);
140
+
137
141
  var _reduceDisplayValues = require('./lib/reduceDisplayValues');
138
142
 
139
143
  var _reduceDisplayValues2 = _interopRequireDefault(_reduceDisplayValues);
@@ -158,10 +162,6 @@ var _styleCache = require('./lib/styleCache');
158
162
 
159
163
  var _styleCache2 = _interopRequireDefault(_styleCache);
160
164
 
161
- var _warnOnce = require('./lib/warnOnce');
162
-
163
- var _warnOnce2 = _interopRequireDefault(_warnOnce);
164
-
165
165
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
166
166
 
167
167
  // Processors
@@ -187,6 +187,7 @@ var processors = {
187
187
  postcssNormalizeCharset: _postcssNormalizeCharset2.default,
188
188
  postcssDiscardOverridden: _postcssDiscardOverridden2.default,
189
189
  normalizeString: _normalizeString2.default,
190
+ normalizeUnicode: _normalizeUnicode2.default,
190
191
  // minify-font-values should be run before discard-unused
191
192
  postcssMinifyFontValues: _postcssMinifyFontValues2.default,
192
193
  postcssDiscardUnused: _postcssDiscardUnused2.default,
@@ -208,10 +209,6 @@ var processors = {
208
209
  styleCache: _styleCache2.default
209
210
  };
210
211
 
211
- /**
212
- * Deprecation warnings
213
- */
214
-
215
212
  var defaultOptions = {
216
213
  autoprefixer: {
217
214
  add: false
@@ -236,6 +233,7 @@ var safeOptions = {
236
233
  },
237
234
  postcssReduceIdents: {
238
235
  counterStyle: false,
236
+ gridTemplate: false,
239
237
  keyframes: false
240
238
  },
241
239
  postcssNormalizeUrl: {
@@ -257,19 +255,30 @@ var cssnano = _postcss2.default.plugin('cssnano', function () {
257
255
 
258
256
  var safe = options.isSafe;
259
257
  var proc = (0, _postcss2.default)();
258
+ var warnings = [];
260
259
 
261
260
  if (typeof options.fontFamily !== 'undefined' || typeof options.minifyFontWeight !== 'undefined') {
262
- (0, _warnOnce2.default)('The fontFamily & minifyFontWeight options have been ' + 'consolidated into minifyFontValues, and are now deprecated.');
261
+ warnings.push('The fontFamily & minifyFontWeight options have been ' + 'consolidated into minifyFontValues, and are now deprecated.');
263
262
  if (!options.minifyFontValues) {
264
263
  options.minifyFontValues = options.fontFamily;
265
264
  }
266
265
  }
267
266
 
268
267
  if (typeof options.singleCharset !== 'undefined') {
269
- (0, _warnOnce2.default)('The singleCharset option has been renamed to ' + 'normalizeCharset, and is now deprecated.');
268
+ warnings.push('The singleCharset option has been renamed to ' + 'normalizeCharset, and is now deprecated.');
270
269
  options.normalizeCharset = options.singleCharset;
271
270
  }
272
271
 
272
+ if (warnings.length) {
273
+ proc.use(_postcss2.default.plugin('cssnano', function () {
274
+ return function (css, result) {
275
+ return warnings.forEach(function (w) {
276
+ return result.warn(w);
277
+ });
278
+ };
279
+ }));
280
+ }
281
+
273
282
  Object.keys(processors).forEach(function (plugin) {
274
283
  var shortName = plugin.replace('postcss', '');
275
284
  shortName = shortName.slice(0, 1).toLowerCase() + shortName.slice(1);
@@ -0,0 +1,67 @@
1
+ 'use strict';
2
+
3
+ exports.__esModule = true;
4
+
5
+ var _postcss = require('postcss');
6
+
7
+ var _postcss2 = _interopRequireDefault(_postcss);
8
+
9
+ var _postcssValueParser = require('postcss-value-parser');
10
+
11
+ var _postcssValueParser2 = _interopRequireDefault(_postcssValueParser);
12
+
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+
15
+ function unicode(range) {
16
+ var values = range.slice(2).split('-');
17
+ if (values.length < 2) {
18
+ return range;
19
+ }
20
+ var left = values[0].split('');
21
+ var right = values[1].split('');
22
+
23
+ if (left.length !== right.length) {
24
+ return range;
25
+ }
26
+
27
+ var questionCounter = 0;
28
+
29
+ var merged = left.reduce(function (group, value, index) {
30
+ if (group === false) {
31
+ return false;
32
+ }
33
+ if (value === right[index] && !questionCounter) {
34
+ return group + value;
35
+ }
36
+ if (value === '0' && right[index] === 'f') {
37
+ questionCounter++;
38
+ return group + '?';
39
+ }
40
+ return false;
41
+ }, 'u+');
42
+
43
+ /*
44
+ * The maximum number of wildcard characters (?) for ranges is 5.
45
+ */
46
+
47
+ if (merged && questionCounter < 6) {
48
+ return merged;
49
+ }
50
+
51
+ return range;
52
+ }
53
+
54
+ exports.default = _postcss2.default.plugin('cssnano-normalize-unicode', function () {
55
+ return function (css) {
56
+ css.walkDecls(/^unicode-range$/i, function (node) {
57
+ node.prop = 'unicode-range';
58
+ node.value = (0, _postcssValueParser2.default)(node.value).walk(function (child) {
59
+ if (child.type === 'word') {
60
+ child.value = unicode(child.value.toLowerCase());
61
+ }
62
+ return false;
63
+ }).toString();
64
+ });
65
+ };
66
+ });
67
+ module.exports = exports['default'];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cssnano",
3
- "version": "3.9.1",
3
+ "version": "3.10.0",
4
4
  "description": "A modular minifier, built on top of the PostCSS ecosystem.",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -76,7 +76,6 @@
76
76
  "eslint-plugin-babel": "^3.3.0",
77
77
  "eslint-plugin-import": "^2.0.1",
78
78
  "gh-pages": "^0.11.0",
79
- "hook-std": "^0.2.0",
80
79
  "json-loader": "^0.5.4",
81
80
  "ncp": "^2.0.0",
82
81
  "nyc": "^10.0.0",
@@ -1,16 +0,0 @@
1
- 'use strict';
2
-
3
- exports.__esModule = true;
4
- exports.default = warnOnce;
5
- var messages = {};
6
-
7
- function warnOnce(message) {
8
- if (messages[message]) {
9
- return;
10
- }
11
- messages[message] = true;
12
- if (typeof console !== 'undefined' && console.warn) {
13
- console.warn(message);
14
- }
15
- }
16
- module.exports = exports['default'];