cssnano 8.0.5 → 8.0.7
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 +6 -6
- package/src/index.js +24 -15
- package/types/index.d.ts +16 -3
- package/types/index.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cssnano",
|
|
3
|
-
"version": "8.0.
|
|
4
|
-
"description": "A modular minifier, built on top of the PostCSS ecosystem.",
|
|
3
|
+
"version": "8.0.7",
|
|
4
|
+
"description": "A modular CSS minifier, built on top of the PostCSS ecosystem.",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./types/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"lilconfig": "^3.1.3",
|
|
31
|
-
"cssnano-preset-default": "^8.0.
|
|
31
|
+
"cssnano-preset-default": "^8.0.7"
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://github.com/cssnano/cssnano",
|
|
34
34
|
"author": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
},
|
|
39
39
|
"repository": {
|
|
40
40
|
"type": "git",
|
|
41
|
-
"url": "cssnano/cssnano"
|
|
41
|
+
"url": "git+https://github.com/cssnano/cssnano.git"
|
|
42
42
|
},
|
|
43
43
|
"files": [
|
|
44
44
|
"src",
|
|
@@ -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.
|
|
59
|
-
"cssnano-preset-lite": "^5.0.
|
|
58
|
+
"cssnano-preset-advanced": "^8.0.7",
|
|
59
|
+
"cssnano-preset-lite": "^5.0.5"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"postcss": "^8.5.26"
|
package/src/index.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
const path = require('node:path');
|
|
3
|
-
/** @type {any} */
|
|
4
3
|
const postcss = require('postcss');
|
|
5
4
|
const { lilconfigSync } = require('lilconfig');
|
|
6
5
|
const defaultPreset = require('cssnano-preset-default');
|
|
7
6
|
|
|
8
7
|
const cssnano = 'cssnano';
|
|
9
8
|
|
|
10
|
-
/** @typedef {{
|
|
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 */
|
|
11
16
|
/**
|
|
12
17
|
* @param {string} moduleId
|
|
13
18
|
* @returns {boolean}
|
|
@@ -28,8 +33,8 @@ function isResolvable(moduleId) {
|
|
|
28
33
|
* preset = function <- to be invoked
|
|
29
34
|
* preset = {plugins: []} <- already invoked function
|
|
30
35
|
*
|
|
31
|
-
* @param {
|
|
32
|
-
* @return {[
|
|
36
|
+
* @param {unknown} preset
|
|
37
|
+
* @return {PresetPlugin[]}
|
|
33
38
|
*/
|
|
34
39
|
function resolvePreset(preset) {
|
|
35
40
|
let fn, options;
|
|
@@ -122,38 +127,42 @@ function resolveConfig(options) {
|
|
|
122
127
|
* @return {import('postcss').Processor}
|
|
123
128
|
*/
|
|
124
129
|
function cssnanoPlugin(options = {}) {
|
|
125
|
-
|
|
130
|
+
/** @typedef {Options & { preset: { plugins: PresetPlugin[] } }} MutableOptions */
|
|
131
|
+
if (Array.isArray(/** @type {MutableOptions} */ (options).plugins)) {
|
|
126
132
|
if (
|
|
127
|
-
!(/** @type {
|
|
128
|
-
!(/** @type {
|
|
133
|
+
!(/** @type {MutableOptions} */ (options).preset) ||
|
|
134
|
+
!(/** @type {MutableOptions} */ (options).preset.plugins)
|
|
129
135
|
) {
|
|
130
|
-
/** @type {
|
|
136
|
+
/** @type {MutableOptions} */ (options).preset = { plugins: [] };
|
|
131
137
|
}
|
|
132
138
|
|
|
133
|
-
const inputPlugins = /** @type {
|
|
134
|
-
/** @type {
|
|
139
|
+
const inputPlugins = /** @type {PluginSpec[]} */ (
|
|
140
|
+
/** @type {MutableOptions} */ (options).plugins
|
|
135
141
|
);
|
|
136
142
|
for (const plugin of inputPlugins) {
|
|
137
143
|
if (Array.isArray(plugin)) {
|
|
138
144
|
const [pluginDef, opts = {}] = plugin;
|
|
139
145
|
if (typeof pluginDef === 'string' && isResolvable(pluginDef)) {
|
|
140
|
-
/** @type {
|
|
146
|
+
/** @type {MutableOptions} */ (options).preset.plugins.push([
|
|
141
147
|
require(pluginDef),
|
|
142
148
|
opts,
|
|
143
149
|
]);
|
|
144
150
|
} else {
|
|
145
|
-
/** @type {
|
|
146
|
-
pluginDef,
|
|
151
|
+
/** @type {MutableOptions} */ (options).preset.plugins.push([
|
|
152
|
+
/** @type {PluginCreator} */ (pluginDef),
|
|
147
153
|
opts,
|
|
148
154
|
]);
|
|
149
155
|
}
|
|
150
156
|
} else if (typeof plugin === 'string' && isResolvable(plugin)) {
|
|
151
|
-
/** @type {
|
|
157
|
+
/** @type {MutableOptions} */ (options).preset.plugins.push([
|
|
152
158
|
require(plugin),
|
|
153
159
|
{},
|
|
154
160
|
]);
|
|
155
161
|
} else {
|
|
156
|
-
/** @type {
|
|
162
|
+
/** @type {MutableOptions} */ (options).preset.plugins.push([
|
|
163
|
+
/** @type {PluginCreator} */ (plugin),
|
|
164
|
+
{},
|
|
165
|
+
]);
|
|
157
166
|
}
|
|
158
167
|
}
|
|
159
168
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
export = cssnanoPlugin;
|
|
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?];
|
|
2
15
|
export type Options = {
|
|
3
|
-
preset?:
|
|
4
|
-
plugins?:
|
|
16
|
+
preset?: PresetSpec;
|
|
17
|
+
plugins?: PluginSpec[];
|
|
5
18
|
configFile?: string;
|
|
6
19
|
};
|
|
7
20
|
/**
|
|
@@ -9,5 +22,5 @@ export type Options = {
|
|
|
9
22
|
* @param {Options=} options
|
|
10
23
|
* @return {import('postcss').Processor}
|
|
11
24
|
*/
|
|
12
|
-
declare function cssnanoPlugin(options?: {}):
|
|
25
|
+
declare function cssnanoPlugin(options?: {}): postcss.Processor;
|
|
13
26
|
//# sourceMappingURL=index.d.ts.map
|
package/types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"SA4LiB,aAAa;OA1LxB,OAAO,WAAW,SAAS;AAM7B,YAA8D,aAAa,GAAjE,OAAO,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,CAAe;AAC3E,YAAgD,aAAa,GAAnD,OAAO,SAAS,EAAE,aAAa,CAAC,GAAG,CAAC,CAAe;AAC7D,YAA0C,YAAY,GAA5C,CAAC,aAAa,EAAE,aAAa,CAAC,CAAc;AACtD,YAA0D,aAAa,GAA7D,CAAC,OAAO,CAAC,EAAE,GAAG,KAAK;IAAE,OAAO,EAAE,YAAY,EAAE,CAAA;CAAE,CAAe;AACvE,YAAmG,UAAU,GAAnG,MAAM,GAAG,aAAa,GAAG,CAAC,MAAM,GAAG,aAAa,EAAE,MAAM,CAAC,GAAG;IAAE,OAAO,EAAE,YAAY,EAAE,CAAA;CAAE,CAAY;AAC7G,YAAsE,UAAU,GAAtE,MAAM,GAAG,aAAa,GAAG,CAAC,MAAM,GAAG,aAAa,EAAE,MAAM,CAAC,CAAC,CAAY;AAChF,YAAgF,OAAO,GAA7E;IAAE,MAAM,CAAC,EAAE,UAAU,CAAC;IAAC,OAAO,CAAC,EAAE,UAAU,EAAE,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAAS;AA6G3F;;;;GAIG;AACH,iBAAS,aAAa,CAAC,OAAO,KAAK,qBAyDlC"}
|