cssnano 8.0.6 → 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 +4 -4
- package/src/index.js +23 -13
- package/types/index.d.ts +14 -2
- package/types/index.d.ts.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cssnano",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.7",
|
|
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.
|
|
31
|
+
"cssnano-preset-default": "^8.0.7"
|
|
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.
|
|
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
|
@@ -6,7 +6,13 @@ const defaultPreset = require('cssnano-preset-default');
|
|
|
6
6
|
|
|
7
7
|
const cssnano = 'cssnano';
|
|
8
8
|
|
|
9
|
-
/** @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 */
|
|
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 {[
|
|
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
|
-
|
|
130
|
+
/** @typedef {Options & { preset: { plugins: PresetPlugin[] } }} MutableOptions */
|
|
131
|
+
if (Array.isArray(/** @type {MutableOptions} */ (options).plugins)) {
|
|
125
132
|
if (
|
|
126
|
-
!(/** @type {
|
|
127
|
-
!(/** @type {
|
|
133
|
+
!(/** @type {MutableOptions} */ (options).preset) ||
|
|
134
|
+
!(/** @type {MutableOptions} */ (options).preset.plugins)
|
|
128
135
|
) {
|
|
129
|
-
/** @type {
|
|
136
|
+
/** @type {MutableOptions} */ (options).preset = { plugins: [] };
|
|
130
137
|
}
|
|
131
138
|
|
|
132
|
-
const inputPlugins = /** @type {
|
|
133
|
-
/** @type {
|
|
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 {
|
|
146
|
+
/** @type {MutableOptions} */ (options).preset.plugins.push([
|
|
140
147
|
require(pluginDef),
|
|
141
148
|
opts,
|
|
142
149
|
]);
|
|
143
150
|
} else {
|
|
144
|
-
/** @type {
|
|
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 {
|
|
157
|
+
/** @type {MutableOptions} */ (options).preset.plugins.push([
|
|
151
158
|
require(plugin),
|
|
152
159
|
{},
|
|
153
160
|
]);
|
|
154
161
|
} else {
|
|
155
|
-
/** @type {
|
|
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?:
|
|
5
|
-
plugins?:
|
|
16
|
+
preset?: PresetSpec;
|
|
17
|
+
plugins?: PluginSpec[];
|
|
6
18
|
configFile?: string;
|
|
7
19
|
};
|
|
8
20
|
/**
|
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"}
|