cssnano-preset-lite 2.1.0 → 2.1.3
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 -6
- package/src/index.js +4 -2
- package/types/index.d.ts +13 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cssnano-preset-lite",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"main": "src/index.js",
|
|
5
5
|
"types": "types/index.d.ts",
|
|
6
6
|
"description": "Safe and minimum transformation",
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"license": "MIT",
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"cssnano-utils": "^3.1.0",
|
|
15
|
-
"postcss-discard-comments": "^5.1.
|
|
16
|
-
"postcss-discard-empty": "^5.1.
|
|
17
|
-
"postcss-normalize-whitespace": "^5.1.
|
|
15
|
+
"postcss-discard-comments": "^5.1.2",
|
|
16
|
+
"postcss-discard-empty": "^5.1.1",
|
|
17
|
+
"postcss-normalize-whitespace": "^5.1.1"
|
|
18
18
|
},
|
|
19
19
|
"repository": "cssnano/cssnano",
|
|
20
20
|
"homepage": "https://github.com/cssnano/cssnano",
|
|
@@ -30,6 +30,5 @@
|
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"postcss": "^8.2.15"
|
|
32
32
|
},
|
|
33
|
-
"scripts": {}
|
|
34
|
-
"readme": "# cssnano-preset-lite\n\n> Safe and minimum transformation with just removing whitespaces, line breaks and comments\n\n## Table of Contents\n\n- [Overview](#overview)\n\n- [Usage](#usage)\n\n - [Install](#install)\n - [Configuration](#configuration)\n\n- [Plugins](#plugins)\n\n - [cssnano-utils](#cssnano-utils)\n - [postcss-discard-comments](#postcss-discard-comments)\n - [postcss-discard-empty](#postcss-discard-empty)\n - [postcss-normalize-whitespace](#postcss-normalize-whitespace)\n\n- [Contributors](#contributors)\n\n- [License](#license)\n\n## Overview\n\nThis lite preset for cssnano only includes transforms that only removes extra whitespace,\nlinebreaks, and comments.\n\n## Usage\n\n### Install\n\nWith [npm](https://npmjs.com/package/cssnano-preset-lite) do:\n\n npm install cssnano-preset-lite --save-dev\n\nIf you don't have npm then [check out this installation tutorial](https://npmjs.com/package/cssnano-preset-lite/tutorial).\n\n### Configuration\n\nIf you would like to use the default configuration, then you don't need to add anything to your `package.json`.\n\nBut should you wish to customise this, you can pass an array with the second parameter as the options object to use. For example, to remove all comments:\n\n```diff\n {\n \"name\": \"awesome-application\",\n+ \"cssnano\": {\n+ \"preset\": [\n+ \"lite\",\n+ {\"discardComments\": {\"removeAll\": true}}\n+ ]\n+ }\n }\n```\n\nDepending on your usage, the JSON configuration might not work for you, such as in cases where you would like to use options with customisable function parameters. For this use case, we recommend a `cssnano.config.js` at the same location as your `package.json`. You can then load a preset and export it with your custom parameters:\n\n```js\nconst defaultPreset = require('cssnano-preset-lite');\n\nmodule.exports = defaultPreset({\n discardComments: {\n remove: (comment) => comment[0] === '@',\n },\n});\n```\n\nNote that you may wish to publish your own preset to npm for reusability, should it differ a lot from this one. This is highly encouraged!\n\n## Plugins\n\n### [`cssnano-utils`](https://github.com/cssnano/cssnano/tree/master/packages/cssnano-utils)\n\n> Utility methods used by cssnano\n\n\n### [`postcss-discard-comments`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-discard-comments)\n\n> Discard comments in your CSS files with PostCSS.\n\nThis plugin is loaded with its default configuration.\n\n### [`postcss-discard-empty`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-discard-empty)\n\n> Discard empty rules and values with PostCSS.\n\nThis plugin is loaded with its default configuration.\n\n### [`postcss-normalize-whitespace`](https://github.com/cssnano/cssnano/tree/master/packages/postcss-normalize-whitespace)\n\n> Trim whitespace inside and around CSS rules & declarations.\n\nThis plugin is loaded with its default configuration.\n\n\n## Contributors\n\nSee [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).\n"
|
|
33
|
+
"scripts": {}
|
|
35
34
|
}
|
package/src/index.js
CHANGED
|
@@ -15,7 +15,7 @@ const defaultOpts = {};
|
|
|
15
15
|
* @param {Options} opts
|
|
16
16
|
* @return {{plugins: [import('postcss').PluginCreator<any>, false | Record<string, any> | undefined][]}}
|
|
17
17
|
*/
|
|
18
|
-
|
|
18
|
+
function defaultPreset(opts = {}) {
|
|
19
19
|
const options = Object.assign({}, defaultOpts, opts);
|
|
20
20
|
/** @type {[import('postcss').PluginCreator<any>, false | Record<string, any> | undefined][]} **/
|
|
21
21
|
const plugins = [
|
|
@@ -26,4 +26,6 @@ module.exports = function defaultPreset(opts = {}) {
|
|
|
26
26
|
];
|
|
27
27
|
|
|
28
28
|
return { plugins };
|
|
29
|
-
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = defaultPreset;
|
package/types/index.d.ts
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
export = defaultPreset;
|
|
2
|
+
/**
|
|
3
|
+
* @param {Options} opts
|
|
4
|
+
* @return {{plugins: [import('postcss').PluginCreator<any>, false | Record<string, any> | undefined][]}}
|
|
5
|
+
*/
|
|
6
|
+
declare function defaultPreset(opts?: Options): {
|
|
2
7
|
plugins: [import('postcss').PluginCreator<any>, false | Record<string, any> | undefined][];
|
|
3
8
|
};
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export type Options = {
|
|
9
|
+
declare namespace defaultPreset {
|
|
10
|
+
export { SimpleOptions, Options };
|
|
11
|
+
}
|
|
12
|
+
type Options = {
|
|
9
13
|
discardComments?: false | import('postcss-discard-comments').Options & {
|
|
10
14
|
exclude?: true;
|
|
11
15
|
};
|
|
@@ -13,4 +17,7 @@ export type Options = {
|
|
|
13
17
|
discardEmpty?: SimpleOptions;
|
|
14
18
|
rawCache?: SimpleOptions;
|
|
15
19
|
};
|
|
20
|
+
type SimpleOptions = false | {
|
|
21
|
+
exclude?: true;
|
|
22
|
+
};
|
|
16
23
|
import { rawCache } from "cssnano-utils";
|