cssnano-preset-lite 3.0.2 → 3.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 +5 -5
- package/src/index.js +50 -19
- package/types/index.d.ts +18 -17
- package/types/index.d.ts.map +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cssnano-preset-lite",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"main": "src/index.js",
|
|
5
5
|
"types": "types/index.d.ts",
|
|
6
6
|
"description": "Safe and minimum transformation",
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
],
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"cssnano-utils": "^4.0.
|
|
15
|
-
"postcss-discard-comments": "^6.0.
|
|
16
|
-
"postcss-discard-empty": "^6.0.
|
|
17
|
-
"postcss-normalize-whitespace": "^6.0.
|
|
14
|
+
"cssnano-utils": "^4.0.2",
|
|
15
|
+
"postcss-discard-comments": "^6.0.2",
|
|
16
|
+
"postcss-discard-empty": "^6.0.3",
|
|
17
|
+
"postcss-normalize-whitespace": "^6.0.2"
|
|
18
18
|
},
|
|
19
19
|
"repository": "cssnano/cssnano",
|
|
20
20
|
"homepage": "https://github.com/cssnano/cssnano",
|
package/src/index.js
CHANGED
|
@@ -4,28 +4,59 @@ const postcssNormalizeWhitespace = require('postcss-normalize-whitespace');
|
|
|
4
4
|
const postcssDiscardEmpty = require('postcss-discard-empty');
|
|
5
5
|
const { rawCache } = require('cssnano-utils');
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
/**
|
|
8
|
+
* @template {object | void} [OptionsExtends=void]
|
|
9
|
+
* @typedef {false | OptionsExtends & {exclude?: true}} SimpleOptions
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {object} LiteOptions
|
|
14
|
+
* @property {SimpleOptions<import('postcss-discard-comments').Options>} [discardComments]
|
|
15
|
+
* @property {SimpleOptions} [normalizeWhitespace]
|
|
16
|
+
* @property {SimpleOptions} [discardEmpty]
|
|
17
|
+
* @property {SimpleOptions} [rawCache]
|
|
18
|
+
*/
|
|
12
19
|
|
|
13
|
-
const defaultOpts = {};
|
|
14
20
|
/**
|
|
15
|
-
* @param {
|
|
16
|
-
* @
|
|
21
|
+
* @param {[import('postcss').PluginCreator<any>, keyof LiteOptions][]} plugins
|
|
22
|
+
* @param {Parameters<typeof litePreset>[0]} opts
|
|
23
|
+
* @returns {ReturnType<typeof litePreset>["plugins"]}
|
|
17
24
|
*/
|
|
18
|
-
function
|
|
19
|
-
const
|
|
20
|
-
/** @type {[import('postcss').PluginCreator<any>, false | Record<string, any> | undefined][]} **/
|
|
21
|
-
const plugins = [
|
|
22
|
-
[postcssDiscardComments, options.discardComments],
|
|
23
|
-
[postcssNormalizeWhitespace, options.normalizeWhitespace],
|
|
24
|
-
[postcssDiscardEmpty, options.discardEmpty],
|
|
25
|
-
[rawCache, options.rawCache],
|
|
26
|
-
];
|
|
25
|
+
function configurePlugins(plugins, opts = {}) {
|
|
26
|
+
const defaults = /** @type {LiteOptions} */ ({});
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
// Merge option properties for each plugin
|
|
29
|
+
return plugins.map(([plugin, opt]) => {
|
|
30
|
+
const defaultProps = defaults[opt] ?? {};
|
|
31
|
+
const presetProps = opts[opt] ?? {};
|
|
32
|
+
|
|
33
|
+
return [
|
|
34
|
+
plugin,
|
|
35
|
+
presetProps !== false
|
|
36
|
+
? { ...defaultProps, ...presetProps }
|
|
37
|
+
: { exclude: true },
|
|
38
|
+
];
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Safe and minimum transformation with just removing whitespaces, line breaks and comments
|
|
44
|
+
*
|
|
45
|
+
* @param {LiteOptions} opts
|
|
46
|
+
* @returns {{ plugins: [import('postcss').PluginCreator<any>, LiteOptions[keyof LiteOptions]][] }}
|
|
47
|
+
*/
|
|
48
|
+
function litePreset(opts = {}) {
|
|
49
|
+
return {
|
|
50
|
+
plugins: configurePlugins(
|
|
51
|
+
[
|
|
52
|
+
[postcssDiscardComments, 'discardComments'],
|
|
53
|
+
[postcssNormalizeWhitespace, 'normalizeWhitespace'],
|
|
54
|
+
[postcssDiscardEmpty, 'discardEmpty'],
|
|
55
|
+
[rawCache, 'rawCache'],
|
|
56
|
+
],
|
|
57
|
+
opts
|
|
58
|
+
),
|
|
59
|
+
};
|
|
29
60
|
}
|
|
30
61
|
|
|
31
|
-
module.exports =
|
|
62
|
+
module.exports = litePreset;
|
package/types/index.d.ts
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
|
-
export =
|
|
1
|
+
export = litePreset;
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Safe and minimum transformation with just removing whitespaces, line breaks and comments
|
|
4
|
+
*
|
|
5
|
+
* @param {LiteOptions} opts
|
|
6
|
+
* @returns {{ plugins: [import('postcss').PluginCreator<any>, LiteOptions[keyof LiteOptions]][] }}
|
|
5
7
|
*/
|
|
6
|
-
declare function
|
|
7
|
-
plugins: [import('postcss').PluginCreator<any>,
|
|
8
|
+
declare function litePreset(opts?: LiteOptions): {
|
|
9
|
+
plugins: [import('postcss').PluginCreator<any>, LiteOptions[keyof LiteOptions]][];
|
|
8
10
|
};
|
|
9
|
-
declare namespace
|
|
10
|
-
export { SimpleOptions,
|
|
11
|
+
declare namespace litePreset {
|
|
12
|
+
export { SimpleOptions, LiteOptions };
|
|
11
13
|
}
|
|
12
|
-
type
|
|
13
|
-
discardComments?:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
discardEmpty?: SimpleOptions;
|
|
18
|
-
rawCache?: SimpleOptions;
|
|
14
|
+
type LiteOptions = {
|
|
15
|
+
discardComments?: SimpleOptions<postcssDiscardComments.Options> | undefined;
|
|
16
|
+
normalizeWhitespace?: SimpleOptions<void> | undefined;
|
|
17
|
+
discardEmpty?: SimpleOptions<void> | undefined;
|
|
18
|
+
rawCache?: SimpleOptions<void> | undefined;
|
|
19
19
|
};
|
|
20
|
-
type SimpleOptions = false | {
|
|
20
|
+
type SimpleOptions<OptionsExtends extends void | object = void> = false | (OptionsExtends & {
|
|
21
21
|
exclude?: true;
|
|
22
|
-
};
|
|
23
|
-
import
|
|
22
|
+
});
|
|
23
|
+
import postcssDiscardComments = require("postcss-discard-comments");
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";AAyCA;;;;;GAKG;AACH,mCAHW,WAAW,GACT;IAAE,OAAO,EAAE,CAAC,OAAO,SAAS,EAAE,aAAa,CAAC,GAAG,CAAC,EAAE,WAAW,CAAC,MAAM,WAAW,CAAC,CAAC,EAAE,CAAA;CAAE,CAcjG;;;;;;;;;;kEAnDY,KAAK,IAAG,cAAc,GAAG;IAAC,OAAO,CAAC,EAAE,IAAI,CAAA;CAAC,CAAA"}
|