cssnano 8.0.6 → 8.0.8

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,6 +1,6 @@
1
1
  {
2
2
  "name": "cssnano",
3
- "version": "8.0.6",
3
+ "version": "8.0.8",
4
4
  "description": "A modular CSS minifier, built on top of the PostCSS ecosystem.",
5
5
  "exports": {
6
6
  ".": {
@@ -28,7 +28,7 @@
28
28
  "license": "MIT",
29
29
  "dependencies": {
30
30
  "lilconfig": "^3.1.3",
31
- "cssnano-preset-default": "^8.0.6"
31
+ "cssnano-preset-default": "^8.0.8"
32
32
  },
33
33
  "homepage": "https://github.com/cssnano/cssnano",
34
34
  "author": {
@@ -55,8 +55,8 @@
55
55
  "autoprefixer": "^10.5.4",
56
56
  "postcss": "^8.5.26",
57
57
  "postcss-font-magician": "^4.0.0",
58
- "cssnano-preset-advanced": "^8.0.6",
59
- "cssnano-preset-lite": "^5.0.4"
58
+ "cssnano-preset-lite": "^5.0.5",
59
+ "cssnano-preset-advanced": "^8.0.8"
60
60
  },
61
61
  "peerDependencies": {
62
62
  "postcss": "^8.5.26"
package/src/index.js CHANGED
@@ -6,7 +6,13 @@ const defaultPreset = require('cssnano-preset-default');
6
6
 
7
7
  const cssnano = 'cssnano';
8
8
 
9
- /** @typedef {{preset?: any, plugins?: any[], configFile?: string}} Options */
9
+ /** @typedef {boolean | { exclude?: boolean } | void | undefined} PluginOptions */
10
+ /** @typedef {import('postcss').PluginCreator<any>} PluginCreator */
11
+ /** @typedef {[PluginCreator, PluginOptions]} PresetPlugin */
12
+ /** @typedef {(options?: any) => { plugins: PresetPlugin[] }} PresetFactory */
13
+ /** @typedef {string | PresetFactory | [string | PresetFactory, object] | { plugins: PresetPlugin[] }} PresetSpec */
14
+ /** @typedef {string | PluginCreator | [string | PluginCreator, object?]} PluginSpec */
15
+ /** @typedef {{ preset?: PresetSpec, plugins?: PluginSpec[], configFile?: string }} Options */
10
16
  /**
11
17
  * @param {string} moduleId
12
18
  * @returns {boolean}
@@ -28,7 +34,7 @@ function isResolvable(moduleId) {
28
34
  * preset = {plugins: []} <- already invoked function
29
35
  *
30
36
  * @param {unknown} preset
31
- * @return {[import('postcss').PluginCreator<any>, boolean | Record<string, any> | undefined][]}}
37
+ * @return {PresetPlugin[]}
32
38
  */
33
39
  function resolvePreset(preset) {
34
40
  let fn, options;
@@ -121,38 +127,42 @@ function resolveConfig(options) {
121
127
  * @return {import('postcss').Processor}
122
128
  */
123
129
  function cssnanoPlugin(options = {}) {
124
- if (Array.isArray(/** @type {Options} */ (options).plugins)) {
130
+ /** @typedef {Options & { preset: { plugins: PresetPlugin[] } }} MutableOptions */
131
+ if (Array.isArray(/** @type {MutableOptions} */ (options).plugins)) {
125
132
  if (
126
- !(/** @type {Options} */ (options).preset) ||
127
- !(/** @type {Options} */ (options).preset.plugins)
133
+ !(/** @type {MutableOptions} */ (options).preset) ||
134
+ !(/** @type {MutableOptions} */ (options).preset.plugins)
128
135
  ) {
129
- /** @type {Options} */ (options).preset = { plugins: [] };
136
+ /** @type {MutableOptions} */ (options).preset = { plugins: [] };
130
137
  }
131
138
 
132
- const inputPlugins = /** @type {any[]} */ (
133
- /** @type {Options} */ (options).plugins
139
+ const inputPlugins = /** @type {PluginSpec[]} */ (
140
+ /** @type {MutableOptions} */ (options).plugins
134
141
  );
135
142
  for (const plugin of inputPlugins) {
136
143
  if (Array.isArray(plugin)) {
137
144
  const [pluginDef, opts = {}] = plugin;
138
145
  if (typeof pluginDef === 'string' && isResolvable(pluginDef)) {
139
- /** @type {Options} */ (options).preset.plugins.push([
146
+ /** @type {MutableOptions} */ (options).preset.plugins.push([
140
147
  require(pluginDef),
141
148
  opts,
142
149
  ]);
143
150
  } else {
144
- /** @type {Options} */ (options).preset.plugins.push([
145
- pluginDef,
151
+ /** @type {MutableOptions} */ (options).preset.plugins.push([
152
+ /** @type {PluginCreator} */ (pluginDef),
146
153
  opts,
147
154
  ]);
148
155
  }
149
156
  } else if (typeof plugin === 'string' && isResolvable(plugin)) {
150
- /** @type {Options} */ (options).preset.plugins.push([
157
+ /** @type {MutableOptions} */ (options).preset.plugins.push([
151
158
  require(plugin),
152
159
  {},
153
160
  ]);
154
161
  } else {
155
- /** @type {Options} */ (options).preset.plugins.push([plugin, {}]);
162
+ /** @type {MutableOptions} */ (options).preset.plugins.push([
163
+ /** @type {PluginCreator} */ (plugin),
164
+ {},
165
+ ]);
156
166
  }
157
167
  }
158
168
  }
package/types/index.d.ts CHANGED
@@ -1,8 +1,20 @@
1
1
  export = cssnanoPlugin;
2
2
  import postcss = require('postcss');
3
+ export type PluginOptions = boolean | {
4
+ exclude?: boolean;
5
+ } | void | undefined;
6
+ export type PluginCreator = import('postcss').PluginCreator<any>;
7
+ export type PresetPlugin = [PluginCreator, PluginOptions];
8
+ export type PresetFactory = (options?: any) => {
9
+ plugins: PresetPlugin[];
10
+ };
11
+ export type PresetSpec = string | PresetFactory | [string | PresetFactory, object] | {
12
+ plugins: PresetPlugin[];
13
+ };
14
+ export type PluginSpec = string | PluginCreator | [string | PluginCreator, object?];
3
15
  export type Options = {
4
- preset?: any;
5
- plugins?: any[];
16
+ preset?: PresetSpec;
17
+ plugins?: PluginSpec[];
6
18
  configFile?: string;
7
19
  };
8
20
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"SAkLiB,aAAa;OAhLxB,OAAO,WAAW,SAAS;AAM7B,YAAgE,OAAO,GAA7D;IAAC,MAAM,CAAC,EAAE,GAAG,CAAC;IAAC,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAC,CAAS;AA6G3E;;;;GAIG;AACH,iBAAS,aAAa,CAAC,OAAO,KAAK,qBAqDlC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"SA4LiB,aAAa;OA1LxB,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