cssnano 5.0.17 → 5.1.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/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "cssnano",
3
- "version": "5.0.17",
3
+ "version": "5.1.0",
4
4
  "description": "A modular minifier, built on top of the PostCSS ecosystem.",
5
5
  "main": "src/index.js",
6
+ "types": "types/index.d.ts",
6
7
  "funding": {
7
8
  "type": "opencollective",
8
9
  "url": "https://opencollective.com/cssnano"
@@ -18,7 +19,7 @@
18
19
  ],
19
20
  "license": "MIT",
20
21
  "dependencies": {
21
- "cssnano-preset-default": "^5.1.12",
22
+ "cssnano-preset-default": "^5.2.0",
22
23
  "lilconfig": "^2.0.3",
23
24
  "yaml": "^1.10.2"
24
25
  },
@@ -31,7 +32,8 @@
31
32
  "repository": "cssnano/cssnano",
32
33
  "files": [
33
34
  "src",
34
- "LICENSE-MIT"
35
+ "LICENSE-MIT",
36
+ "types"
35
37
  ],
36
38
  "bugs": {
37
39
  "url": "https://github.com/cssnano/cssnano/issues"
@@ -41,8 +43,8 @@
41
43
  },
42
44
  "devDependencies": {
43
45
  "autoprefixer": "^10.3.7",
44
- "cssnano-preset-advanced": "^5.1.12",
45
- "cssnano-preset-lite": "^2.0.3",
46
+ "cssnano-preset-advanced": "^5.2.0",
47
+ "cssnano-preset-lite": "^2.1.0",
46
48
  "postcss": "^8.2.15"
47
49
  },
48
50
  "peerDependencies": {
package/src/index.js CHANGED
@@ -1,12 +1,14 @@
1
1
  'use strict';
2
2
  const path = require('path');
3
+ /** @type {any} */
3
4
  const postcss = require('postcss');
4
5
  const yaml = require('yaml');
5
6
  const { lilconfigSync } = require('lilconfig');
6
7
 
7
8
  const cssnano = 'cssnano';
8
9
 
9
- /*
10
+ /** @typedef {{preset?: any, plugins?: any[], configFile?: string}} Options */
11
+ /**
10
12
  * @param {string} moduleId
11
13
  * @returns {boolean}
12
14
  */
@@ -19,14 +21,16 @@ function isResolvable(moduleId) {
19
21
  }
20
22
  }
21
23
 
22
- /*
24
+ /**
23
25
  * preset can be one of four possibilities:
24
26
  * preset = 'default'
25
27
  * preset = ['default', {}]
26
28
  * preset = function <- to be invoked
27
29
  * preset = {plugins: []} <- already invoked function
30
+ *
31
+ * @param {any} preset
32
+ * @return {[import('postcss').PluginCreator<any>, boolean | Record<string, any> | undefined][]}}
28
33
  */
29
-
30
34
  function resolvePreset(preset) {
31
35
  let fn, options;
32
36
 
@@ -71,22 +75,24 @@ function resolvePreset(preset) {
71
75
  );
72
76
  }
73
77
 
74
- /*
78
+ /**
75
79
  * cssnano will look for configuration firstly as options passed
76
80
  * directly to it, and failing this it will use lilconfig to
77
81
  * load an external file.
78
- */
79
82
 
83
+ * @param {Options} options
84
+ */
80
85
  function resolveConfig(options) {
81
86
  if (options.preset) {
82
87
  return resolvePreset(options.preset);
83
88
  }
84
89
 
90
+ /** @type {string | undefined} */
85
91
  let searchPath = process.cwd();
86
- let configPath = null;
92
+ let configPath = undefined;
87
93
 
88
94
  if (options.configFile) {
89
- searchPath = null;
95
+ searchPath = undefined;
90
96
  configPath = path.resolve(process.cwd(), options.configFile);
91
97
  }
92
98
 
@@ -116,7 +122,12 @@ function resolveConfig(options) {
116
122
  return resolvePreset(config.config.preset || config.config);
117
123
  }
118
124
 
119
- const cssnanoPlugin = (options = {}) => {
125
+ /**
126
+ * @type {import('postcss').PluginCreator<Options>}
127
+ * @param {Options=} options
128
+ * @return {import('postcss').Plugin}
129
+ */
130
+ function cssnanoPlugin(options = {}) {
120
131
  if (Array.isArray(options.plugins)) {
121
132
  if (!options.preset || !options.preset.plugins) {
122
133
  options.preset = { plugins: [] };
@@ -154,7 +165,7 @@ const cssnanoPlugin = (options = {}) => {
154
165
  }
155
166
  }
156
167
  return postcss(plugins);
157
- };
168
+ }
158
169
 
159
170
  cssnanoPlugin.postcss = true;
160
171
  module.exports = cssnanoPlugin;
@@ -0,0 +1,16 @@
1
+ export = cssnanoPlugin;
2
+ /**
3
+ * @type {import('postcss').PluginCreator<Options>}
4
+ * @param {Options=} options
5
+ * @return {import('postcss').Plugin}
6
+ */
7
+ declare function cssnanoPlugin(options?: Options | undefined): import('postcss').Plugin;
8
+ declare namespace cssnanoPlugin {
9
+ export { postcss, Options };
10
+ }
11
+ type Options = {
12
+ preset?: any;
13
+ plugins?: any[];
14
+ configFile?: string;
15
+ };
16
+ declare var postcss: true;